Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Env modification increments server port #54574

Open
HugoHeneault opened this issue Feb 12, 2025 · 6 comments · May be fixed by #54606
Open

Env modification increments server port #54574

HugoHeneault opened this issue Feb 12, 2025 · 6 comments · May be fixed by #54606
Labels

Comments

@HugoHeneault
Copy link

HugoHeneault commented Feb 12, 2025

As seen recenlty in that old issue :

#34121 (comment)

This happend to me right now on lates Laravel and PHP installed from brave on mac.


   INFO  Server running on [http://127.0.0.1:8000].  



  Press Ctrl+C to stop the server





   INFO  Environment modified. Restarting server...  



  Failed to listen on 127.0.0.1:8000 (reason: Address already in use)



   INFO  Server running on [http://127.0.0.1:8001].  



  Press Ctrl+C to stop the server

And when i stop server using ctrl+c all process are stoped and when i start server again is on 8000 again...

Originally posted by @gavalierm in #34121

I am also encoutering that with that config:

php -v
PHP 8.3.13 (cli) (built: Oct 22 2024 18:39:14) (NTS)

php artisan --version
Laravel Framework 11.42.0
macOS 15.3 (24D60)

Any ideas of what's going on? How could I help debug that issue?

@PKDmeDEV
Copy link

Same faced by me.

@crynobone
Copy link
Member

Can you share the output of following command:

php --ri pcntl

@gavalierm
Copy link

pcntl

pcntl support => enabled
  INFO  Environment modified. Restarting server...  

  Failed to listen on 127.0.0.1:8002 (reason: Address already in use)

   INFO  Server running on [http://127.0.0.1:8003].  

  Press Ctrl+C to stop the server


   INFO  Environment modified. Restarting server...  

  Failed to listen on 127.0.0.1:8003 (reason: Address already in use)

   INFO  Server running on [http://127.0.0.1:8004].  

  Press Ctrl+C to stop the server


   INFO  Environment modified. Restarting server...  

  Failed to listen on 127.0.0.1:8004 (reason: Address already in use)

   INFO  Server running on [http://127.0.0.1:8005].  

  Press Ctrl+C to stop the server

on latest

@HugoHeneault
Copy link
Author

pcntl

pcntl support => enabled
  INFO  Environment modified. Restarting server...  

  Failed to listen on 127.0.0.1:8002 (reason: Address already in use)

   INFO  Server running on [http://127.0.0.1:8003].  

  Press Ctrl+C to stop the server


   INFO  Environment modified. Restarting server...  

  Failed to listen on 127.0.0.1:8003 (reason: Address already in use)

   INFO  Server running on [http://127.0.0.1:8004].  

  Press Ctrl+C to stop the server


   INFO  Environment modified. Restarting server...  

  Failed to listen on 127.0.0.1:8004 (reason: Address already in use)

   INFO  Server running on [http://127.0.0.1:8005].  

  Press Ctrl+C to stop the server

on latest

Same for me.

@crynobone
Copy link
Member

Can you try changing the following .env configuration

-PHP_CLI_SERVER_WORKERS=4
+PHP_CLI_SERVER_WORKERS=1

@HugoHeneault
Copy link
Author

a serve
  number of workers must be larger than 1

   INFO  Server running on [http://127.0.0.1:8000].  

  Press Ctrl+C to stop the server


   INFO  Environment modified. Restarting server...  

  number of workers must be larger than 1

   INFO  Server running on [http://127.0.0.1:8000].  

  Press Ctrl+C to stop the server

  2025-02-13 15:45:46 / .............................................................................. ~ 505.30ms
  2025-02-13 15:45:46 ................................................................................ ~ 506.33ms

   INFO  Environment modified. Restarting server...  

  number of workers must be larger than 1

   INFO  Server running on [http://127.0.0.1:8000].  

  Press Ctrl+C to stop the server

Seems to be working now (with a message number of workers must be larger than 1)

crynobone added a commit that referenced this issue Feb 14, 2025
By default, serve command would restart child process when there's
modification to the `.env` file. However, with `PHP_CLI_SERVER_WORKERS`
set to larger than 1 the process doesn't close properly (port is still
being used) and this cause the restart process to pick an incremented
port number.

The changes here will unset `PHP_CLI_SERVER_WORKERS` value unless the
command is executed with `--no-reload` option.

fixes #54574

Signed-off-by: Mior Muhammad Zaki <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants