How to Change the Default Symfony Web Server Host and Port

322 views Asked by At

I'm trying to configure the Symfony web server to listen on a custom host (0.0.0.0) and port (e.g., 8080) instead of the default 127.0.0.1:8000. However, despite making changes to the configuration, the Symfony server continues to use the default host and port settings.

Here's what I've done:

  1. I modified the .env file to include the following lines:

    APP_ENV=dev
    
    APP_SECRET=SECRET
    
    APP_HOST=0.0.0.0
    
    APP_PORT=8080
    
  2. I've run symfony server:stop to ensure there are no conflicts with any previous instances of the server.

  3. When I run symfony server:start, I get the following output:

    Web server listening The Web server is using PHP CGI 8.2.4 https://127.0.0.1:8000

Despite specifying the custom host and port in the .env file, it doesn't seem to be taking effect. The server continues to listen on the default 127.0.0.1:8000.

How can I change the default Symfony web server host and port to use the custom settings (0.0.0.0:8080) defined in the .env file?

Are there any additional configurations or commands I need to use to ensure that Symfony recognizes and uses the custom host and port settings?

1

There are 1 answers

1
Mihokyo On

Symfony CLI version 5.7.0 (c)

At least, you can specify port on CLI

symfony server:start --port=8080