You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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
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.
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.
Activity
talldan commentedon Apr 18, 2023
@HeikoMamerow Thanks for reaching out.
PRs are definitely welcome. The only thing is that
envdoesn'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.
noahtallen commentedon Apr 21, 2023
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
HeikoMamerow commentedon Apr 23, 2023
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.
HeikoMamerow commentedon May 3, 2023
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?
chore(env): start RP pipeline 49843-wp-env-default-port-fallback
feat(env): auto-fall-back to free port when defaults busy
docs(env): document default auto-port fallback
youknowriad commentedon Oct 6, 2026
Thanks for proposing this! wp-env can now pick free ports automatically: run
wp-env start --auto-port(or set"autoPort": truein.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.