A 502 Bad Gateway error means a server acting as a gateway or proxy in front of your website received an invalid response from the server actually processing the request. It is not the same as a 404 (page not found) or 403 (permission denied): it usually points to a problem on the server side rather than a broken link or missing file.
What causes a 502 error
A few things commonly trigger this error:
- The web server process (such as PHP-FPM, Apache, or LiteSpeed) crashed or restarted while handling a request.
- A faulty plugin, theme, or piece of custom code (common on WordPress sites) caused the application to fail to respond in time.
- The server is temporarily overloaded with traffic or a runaway script.
- A content delivery network or proxy service sitting in front of your site (if you use one) lost its connection to your hosting server.
- Scheduled maintenance or a brief restart on the hosting server.
Steps to fix it
- Wait a minute or two and refresh the page. Many 502 errors are brief and clear up on their own once a server process restarts.
- Check whether the site is down for everyone or just you. If you are not sure, a quick outage check can rule out a local network or browser issue before you dig further.
- If you recently installed or updated a plugin, theme, or piece of code, that is the first suspect. Rename its folder in File Manager (or over FTP) to temporarily disable it and see if the error clears.
- Check whether you have a large import, export, or cron job running around the same time the error appeared. A script using too much memory or CPU can cause the server to drop the connection.
- If you run your site through a CDN or proxy service, temporarily pause or bypass it and load the site directly to see if the error is happening on their end or on the hosting server.
- Check your website's error logs for the exact moment the 502 occurred. This often shows which script or process failed.
In cPanel
Go to Metrics and open Errors to view the most recent entries in your error log.
In DirectAdmin
Go to Statistics and Logs and open the Error Log for your domain.
If the error only appeared once and has not come back, you likely do not need to do anything further. If it keeps recurring, that is a sign something (a plugin, a script, or resource usage) needs a permanent fix rather than a refresh.
If you have gone through these steps and the error is still there, get in touch with support with the approximate time the error occurred. That timestamp makes it much faster to trace in the server logs.