V7.2.1 - Local's router is having trouble starting [bind() Address already in use]

What issue or error are you experiencing?

After the update of 7.2.1 I got the error “2023/09/20 14:23:14 [emerg] 14364#0: bind() to failed (98: Address already in use)”. This happens even after downgrading and on all websites.

I have manually checked if there are another processes running on the same port, as well as port 80/443. There were no other processes running on these ports. The process on port 10120 (nginx) was running twice however.

What steps can be taken to replicate the issue? Feel free to include screenshots, videos, etc

Starting the website causes the website.

System Details

  • Local Version: 7.2.1

  • Operating System (OS) and OS version: Ubuntu 20.04.6

Local Logs

Attach your Local Logs here (Help Doc - Retrieving Local’s Log)

local-lightning.log (284.7 KB)

Security Reminder
Local does a pretty good job of scrubbing private info from the logs and the errors it produces, however there’s always the possibility that something private can come through. Because these are public forums, always review the screenshots you are sharing to make sure there isn’t private info like passwords being displayed.

Hi @maartendwd!

Were you able to get things going again after killing the duplicate process or are you still having issues?

Can you change your Router Mode to see if that helps? Preferences>Advanced>Router Mode

Unfortunately not. I am still having issues with this. The processes would be added again after killing them.

I have tried with the Localhost Router mode. I do receive an error when trying to update the host settings as well. I suspect this is a permissions issue all together, but I’m unsure how to solve this.

The error I receive from the updating the host:

I double checked the rights for /etc/hosts. These are 644.

Is there anything else I could try? Is reinstalling the program a possibility (would I have to back-up my local environments)?

If you wanted to refresh and start with a clean slate you could give the below steps a try:

  • Export any sites that you have on Local and save them to a folder somewhere on your computer.

  • Fully uninstall Local from your computer.

  • Install the latest version of Local on this link.

  • Once installed, please restart the computer.

  • When the computer is restarted and turned on, close any applications that automatically run in the background (AntiVirus, Firewall, and other Developer applications included).

  • Check and see if the issue still persists. If so, please provide us with an updated log. Retrieving Local’s Log File

1 Like

I had done a full reinstall of Local on my computer, but the same error occured unfortunately. The localhost did work, but Site domains did not work. I have since put my old files back and I am trying to find a solution for this error. I have given some more information below:

  • UFW is inactive

  • There is no service active for port 80.

  • I am still receive the error “2023/09/21 11:03:06 [emerg] 19421#0: bind() to failed (13: Permission denied)” or “2023/09/20 14:23:14 [emerg] 14364#0: bind() to failed (98: Address already in use)” from the logs inside the project.

local-lightning.log (2.0 KB)

Do you have any ideas on what I could try to resolve this issue?

Glad to hear that Localhost at least functions as a workaround. Are you able to work in Localhost or is the limited functionality of it a problem?

Are you running other developer applications simultaneously? That could also cause similar issues. Apps like MAMP, XAMPP, or Docker for example.

Do you have any antivirus, security, or firewall applications that could be running interference?

I do need the Site domains for multisite solutions and ease of work. I would like to get it resolved if possible. I do also work with Bedrock and are comfortable changing the nginx settings for the /web subfolder.

I do not have another application like MAMP, XAMPP or Docker running.

I also do not have any antivirus, security or firewall applications running.

I’m sorry Local isn’t working for you with site domains, @maartendwd. I’m a developer on the Local team interested in helping you to fix this.

I looked at the logs you helpfully shared and saw this line repeated, reformatted for clarity:

Error: User did not grant permission.
Error executing command as another user: Request dismissed

This message could appear on Linux if Local presented someone with a dialog like the one below, and they chose “cancel”, accidentally pressed escape, or otherwise dismissed the prompt instead of entering their password and clicking “authenticate”:

I appreciate that Local should do a better job of explaining this, but it asks for your password here if it needs to run a command with sudo — in this case so it can set capabilities on the nginx binary that Local ships with to run sites in domain mode (this binary is separate to any copies of nginx you may have on your system already).

When those capabilities are not set, Local’s nginx may have trouble binding to ports below 1024 when it runs as a non-root user. This seems to match your experience where nginx can not use port 80 ("nginx: [emerg] bind() to failed is also present in your logs).

To fix it and help Local’s router start correctly when using site domains, try this:

To make Local correct nginx capabilities for you

On Linux, you can make Local check for missing capabilities and correct them for you:

  1. Stop any running sites.
  2. Check that the router mode is set to “site domains” under Local Preferences → Advanced.
  3. Quit and reopen Local.
  4. Try to start a site.
  5. Wait for Local to show you an “Authentication Required” dialog like the one above. (It can take a few seconds.) Type your password and click “Authenticate”.

Local will update the nginx binary capabilities and the nginx proxy should then run as expected.

To correct nginx capabilities manually (if you see no dialog)

If you see no dialog in step 5, you are welcome to try setting capabilities on the nginx binary manually.

For future readers of this thread, the steps below are not required on Windows or macOS, only Linux. You only need to attempt this change on Linux if your sites are not loading in site domains router mode (the default), you are seeing ‘bind() to failed’ in your logs, and you have not seen the dialog above when restarting Local and starting a site.

  1. Stop all sites.

  2. Check that the router mode is set to “site domains” under Local Preferences → Advanced.

  3. Close Local.

  4. Open a terminal and run:
    ls ~/.config/Local/lightning-services | grep nginx

    If you see one result — such as nginx-1.16.0+6 — copy the full output to your clipboard.

    If you see multiple results, copy the nginx string with the highest version number.

  5. Now run the command below, replacing [nginx-version] (deleting the square brackets too) with the nginx version you copied from the previous step, then enter your password when prompted:

     sudo setcap cap_net_bind_service=+ep ~/.config/Local/lightning-services/[nginx-version]/bin/linux/sbin/nginx

    For example, if the nginx version is nginx-1.16.0+6, you would run this:

    sudo setcap cap_net_bind_service=+ep ~/.config/Local/lightning-services/nginx-1.16.0+6/bin/linux/sbin/nginx

    You should see no output after inputting your password and pressing enter.

  6. Confirm that nginx’s capabilities are now correct, replacing [nginx-version] again:

    getcap ~/.config/Local/lightning-services/[nginx-version]/bin/linux/sbin/nginx

    For example, using our previous string, and noting that no sudo is required for getcap:

    getcap ~/.config/Local/lightning-services/nginx-1.16.0+6/bin/linux/sbin/nginx

    The output from the getcap command should end with “nginx cap_net_bind_service=ep”.

  7. Open Local. You should now be able to start sites.

If you need further help looking into this, please let us know.


Thank you for the detailed explanation! I decided to reinstall my OS, but I think this post is helpful for others as well!


This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.