Skip to content

wp-env: consideration of active ports #49843

Closed

Description

@HeikoMamerow

What problem does this address?

wp-env is a very fast and handy tool if you can use it "out of the box" - without configuration. However, most of the time I have to configure custom ports because the default port (8888) is already occupied on my machine. This is very time consuming and annoying.

What is your proposed solution?

The problem can be solved by generating a random port number and check if this port is already open. If the port is open, then a new number is generated and checked.

I had already written a helper script for this task: https://github.com/HeikoMamerow/wp-env-port-stamp

Is it possible to include such a port check in wp-env? I could develop the feature and submit it as PR if that's ok.

PS: I have no experience with contributions for Gutenberg so far. 🙈 But i am very interested to include this feature. 💪

Activity

  1. talldan commented on Apr 18, 2023

    @talldan
    Contributor

    @HeikoMamerow Thanks for reaching out.

    Is it possible to include such a port check in wp-env? I could develop the feature and submit it as PR if that's ok.

    PRs are definitely welcome. The only thing is that env doesn't currently have many contributors/maintainers, so there may be a lack of code reviewers/approvers.

    It looks like only simple documentation changes have been merged in the last six months. So you may want to make a call on the effort/reward.

  2. noahtallen commented on Apr 21, 2023

    @noahtallen
    Member

    Happy to review and test a PR for this based on your existing script! I would expect it to run during wp-env start, and I think it would be fine for it to be unique each time. If people need the port to stay the same, they can set it in .wp-env.json

  3. HeikoMamerow commented on Apr 23, 2023

    @HeikoMamerow
    Author

    Thank you very much for your answers! This makes me very confident that it is worthwhile to implement this task. I will start the implementation next week.

    @noahtallen I completely agree with you. Port management should be done by default at startup. I think it should be so that the original default ports (8888/8889) are checked first and if already active, then another one will used that is not yet active.

    The port management should also be optionally "deactivatable", so that it is possible to define own ports.

  4. HeikoMamerow commented on May 3, 2023

    @HeikoMamerow
    Author

    Aaargh, I had completed my changes and now wanted to start a PR. But after the sync I see that the origin port handling was completely rewritten. 😢

    However - this was my changes: trunk...HeikoMamerow:gutenberg:env/feat/port_management

    What now? Of course my changes do not work with the current version. I may start again...

    How can this be better coordinated? What can i do?

  5. youknowriad commented on Oct 6, 2026

    @youknowriad
    Contributor

    Thanks for proposing this! wp-env can now pick free ports automatically: run wp-env start --auto-port (or set "autoPort": true in .wp-env.json), and when a configured port is busy it scans upward to the next free one. This shipped in #74472. It's opt-in so the long-standing 8888/8889 behaviour stays the same for everyone else. Closing as fixed. Please open a new issue if something about it doesn't fit your workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions