Skip to content

[DX] Smarter web server commandsΒ #21040

Closed
@javiereguiluz

Description

@javiereguiluz
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Symfony version 3.3

Problem

When using the server:start command in several apps, you must provide a free port number to avoid errors like this one:

$ ./bin/console server:start
  [OK] Web server listening on http://127.0.0.1:8000

(change to other app in other directory)

$ ./bin/console server:start
  [ERROR] A process is already listening on http://127.0.0.1:8000

$ ./bin/console server:start 127.0.0.1:8001
  [ERROR] A process is already listening on http://127.0.0.1:8001

$ ./bin/console server:start 127.0.0.1:8002
  [ERROR] A process is already listening on http://127.0.0.1:8002

  fffffuuuuuuuuuuuu !!!!

Solution

If it's technically possible, I'd like the server:start command to look for a free port automatically. Starting from 8000, check the following N ports and pick the first one available.

Same example as before:

$ ./bin/console server:start
  [OK] Web server listening on http://127.0.0.1:8000

(change to other app in other directory)

$ ./bin/console server:start
  [OK] Web server listening on http://127.0.0.1:8024

Depending on how fast/slow is this process, we could check 10, 100 or 1,000 ports before showing the error message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DXDX = Developer eXperience (anything that improves the experience of using Symfony)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions