502 Gateway

What issue or error are you experiencing?

I have a issue bad gateway 502 on only 1 site?

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

System Details

  • Local Version:

  • Operating System (OS) and OS version:

Local Logs

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

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 @Mbenz38

If you create a new, blank site in Local do you get a 502 error?

If you change your Router Mode to Localhost are you able to proceed?

Preferences>Advanced>Router Mode>Localhost

If you’re still having trouble could you provide some more details here?

  • What is your OS?

  • What version of Local are you on?

  • Please attach a copy of your Local Logs

Keep us posted and we’d be happy to help further!

I have the same problem. I don’t see the 502 error with any other website, just one. The router mode change did not help. I’m on macOS Sonoma (14.2.1), Local version 8.2.0+6554, and the Local logs file is attached.
local-lightning.log (838.3 KB)

Hi @kghajar

Based on the logs it looks like there might be a port conflict occurring. Here are some steps to help us identify and address this:

  • Stop all sites that are running in Local

  • Force quit Local

  • (If using Mac) Run the command lsof -nP -iTCP -sTCP:LISTEN

  • (If using Windows) Run the command netstat -ano

What you’ll be looking for here is to see when sites are stopped and Local is properly shut down if there are still programs running on ports 80 and 443. These may be conflicting with Local or the system may be reporting Local is still running.

Once you run that command you should see a list of listening ports. If you see a particular program making use of those ports, you can then kill that process by running sudo kill -9 XXX where XXX is the PID number of that process. (On Windows you will use taskkill /F /pid XXX where XXX is the PID number of that process)

After that, you should be able to retry. Keep us posted if you have any questions or continuing issues.

There are also some more details around this and other troubleshooting steps at this link if needed: Stopping Whatever Is Listening On Port 80.

Hi @Nick-B

Thanks for the reponse. I tried this on macOS and it worked for a day. Now, all websites on Local give me a 502 - Bad Gateway error. I have tried killing processes on 80 and 443 ports as you mentioned and cleared everything in the lightning-services directory, but no luck. I have been using Local for more than a year, and this had not ever happened. What is the issue?

Found the issue in my case. It was happening on all websites that I had the Wordfence plugin installed and that was somehow messing with the nginx config! with its firewall so I used this command in the site shell terminal and deactivated Wrodfence plugin that fixed the issue:

wp plugin deactivate wordfence

Thank you for coming back and sharing your resolution here @kghajar - Glad you got things working :slight_smile:

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