Local Community

502 Request Error for Local Sites

This often shows up as an error within the Browser looking like this:

A 502 error specifically means that the webserver is waiting for something “upstream” and never got a response before eventually timing out. In the case of Local sites, the server is either nginx or apache and the upstream part is the MySQL database.

In most cases, this error is due to the site not being fully “turned on” when the browser tries to access it, so waiting a little bit (not more than a minute or so) and refreshing the browser can help.

Keeping in mind the above error message about waiting for the database to respond – a 502 could be due to other things like the database crashing, or some other thing preventing the database from fully starting.

You can get a good idea of the issues that MySQL is encountering by looking MySQL’s error log which is found in thelogs/mysql/error.log file.

Troubleshooting Steps

The first thing to try is waiting for the site to fully turn on and continue to refresh the browser. This shouldn’t take more than a minute or so.

If waiting for the site to fully turn on doesn’t fix the issue, here are a couple of additional troubleshooting steps I would recommend:

  • Restart the VM by going to “Help > Restart Virtual Machine”
  • Restart the computer and re-try using Local
  • Sometimes the folders that are mounted within the virtual machine become bad, so refreshing those helps. To do this, try toggling “Faster Docker Volumes” from “Preferences > Advanced” and then attempt to create a new test site.

If none of those things work, then it’s likely that the database has become corrupted. You will need to re-import the site or sites by zipping up each site folder and dragging and dropping the zip file onto Local. This will create a site with a new container.