Reputation: 11
I run symfony serve
, Symfony tell me that started server on http://127.0.0.1:8000
, but this port not work (ERR_CONNECTION_REFUSED
).
But on terminal below Symfony say: [Web Server ] May 7 18:31:38 |INFO | PHP listening path="/usr/bin/php7.4" php="7.4.3" port=35823
and adress http://127.0.0.1:35823
is working.
The port is always different every symfony serve
run.
Info about enviroments:
PHP 7.4.3 (cli) (built: Mar 2 2022 15:36:52) ( NTS )
Symfony CLI version 5.4.8
Composer version 2.3.5
Server version: Apache/2.4.41 (Ubuntu)
Upvotes: 1
Views: 1156
Reputation: 1
I have this problem aswell with using wsl on Windows. I haven't really found a solution to this, but instead of using 127.0.0.1:8000 you can use localhost:8000. This is because wsl has its own ip. You can check it using ifconfig
. Because of that it doesn't know 127.0.0.1. So hosting something from wsl to Windows, always goes trough localhost.
This doesn't fix the problem that it starts a second server on a random port. I dont really know why it does this for me aswell. My guess is that it has to do something with how wsl and Windows communicate, since i dont have this problem with Mac.
Upvotes: 0
Reputation: 33
I have the same issue. But even if I try to serve on another port (for example symfony serve --port=55588
), it will still serve on another random port that's different every time...
In this example, 127.0.0.1:55588
doesn't work, but 127.0.0.1:42311
works.
Upvotes: 0
Reputation: 36
Because port 8000 is already used by another service you can check by this all ports by this commande
sudo lsof -i -P -n | grep LISTEN
Or only port 8000
lsof -i :8000
Upvotes: 0