Make TCP Port editable

Hi guys,

thanks for the awesome work.

Could you also make the TCP ports that the local instances are using visible and editable from the admin panel?

Thanks so much xoxox

Hi @daniele.carlone! Thank you for the feature request. What are you looking to do with the editable TCP port?

I was wondering if the ports are randomly assigned or I can manually choose the port for every instance of local sites. I belive that would be really useful for instances in which I have code that interacts with other local machines (outside the wp-engin local domain).

At the moment I have to change the port in the code everytime I spin a new server up.

Thanks a lot.

Bests,

D.

Thanks for the response, @daniele.carlone, that helps us understand your goals.

How Local assigns ports

Local automatically picks a port in the range of 10000–65534 for its services.

It also uses a couple of other ports for its router (80, 443) and API (4000).

How to avoid conflicts with your own services

If your own services need port 80 or 443, you can try running Local in localhost mode (Preferences → Advanced, set “Router mode” to “localhost”), which will give your sites a custom port instead of using Local’s router on port 80. (Best to restart Local after making this change.)

If your services are conflicting with Local services other than ports 80/443, you could pick a port in the range of 8000-9000 for services you’re running outside of Local. That should reduce the chance of conflicts with Local and avoid you having to change ports in Local because Local starts assigning ports at 10000.

Choosing a port

Once Local’s ports are assigned they should not change, so you can write code to connect to the port that Local assigns. But if you really need to choose a port in Local, you can:

  • Stop Local.
  • Edit your sites.json file to manually choose ports.
  • Start Local again.

Those ports should then be static and stable as long as they don’t conflict with each other or with external services (Local will reassign them in those cases).

Making ports editable via the UI

We don’t have immediate plans to expose custom ports in Local’s UI, but it might be a good case for and add-on: https://localwp.com/get-involved/build/