Set custom port when starting symfony local web server

15k Views Asked by At

I want to start a server with symfony server:start using the port that is set in my .env file. Is there a way to do this?

2

There are 2 best solutions below

0
fliim On
php bin/console server:start --help

Gives the info you want

Usage:
  server:start [options] [--] [<addressport>]

Arguments:
  addressport            The address to listen to (can be address:port, address, or port)

So type

Change the default address and port by passing them as an argument:

php bin/console server:start 127.0.0.1:8080
0
Amelia Magee On

For anyone stumbling here from google like I did, use the flag --port=PORTNUMBER

Example:

symfony server:start --port=8080

OR

php bin/console server:start --port=8080

The help page documentation states this like so:

--port=value Preferred HTTP port [default: 8000]