Skip to content

[8.x] Local dev server spawns a new server on port number + 1 when environment reloaded #34121

Closed
@vaughany

Description

@vaughany
  • Laravel Version: 8.x-dev
  • Jetstream Version: 0.6.0
  • PHP Version: 7.4.9
  • Database Driver & Version: SQLite 3.22

Description:

Development server (run with ./artisan serve) cannot listen on same port after .env file reloaded, and starts another server on one port higher. The existing dev server is not shut down when the .env file is edited and saved, so the port's already in use.

Steps To Reproduce:

  1. Create fresh Laravel project using the new installer: laravel new foo --jet --dev.
  2. Configure the database details in .env, then run migrations with ./artisan migrate:fresh.
  3. Serve the project with ./artisan serve - a local dev server is successfully started on port 8000
  4. Modify the .env file and save - a new local dev server is started on port 8001
  5. http://localhost:8000 and http://localhost:8001 both serve my project.
paul@ubuntu:~/projects/foo$ ./artisan serve
Starting Laravel development server: http://127.0.0.1:8000
[Thu Sep  3 16:56:31 2020] PHP 7.4.9 Development Server (http://127.0.0.1:8000) started
[Thu Sep  3 16:56:45 2020] 127.0.0.1:51424 Accepted
[Thu Sep  3 16:56:45 2020] 127.0.0.1:51424 Closing

# .env file is modified.

Environment modified. Restarting server...
[Thu Sep  3 16:57:42 2020] Failed to listen on 127.0.0.1:8000 (reason: Address already in use)
Starting Laravel development server: http://127.0.0.1:8001
[Thu Sep  3 16:57:42 2020] PHP 7.4.9 Development Server (http://127.0.0.1:8001) started

# .env file is modified again.

Environment modified. Restarting server...
[Thu Sep  3 16:58:25 2020] Failed to listen on 127.0.0.1:8001 (reason: Address already in use)
Starting Laravel development server: http://127.0.0.1:8002
[Thu Sep  3 16:58:25 2020] PHP 7.4.9 Development Server (http://127.0.0.1:8002) started

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions