You click a link, wait a second, and instead of the page you wanted, your screen shows “502 Bad Gateway.” No article, no product page, no login form. Just an error.
A 502 Bad Gateway error means a server acting as a gateway or proxy tried to get a response from another server (the “upstream” server) to complete your request, and that response was invalid, garbled, or never came through properly. The gateway itself is usually fine. It’s the server behind it, the one actually doing the work, that dropped the ball.
This isn’t the same as a “site not found” error. The website exists, the domain resolves, but something in the chain between your browser and the server actually running the site broke down.
Where the 502 Error Actually Comes From
Most modern websites don’t run on a single server anymore. There’s usually a reverse proxy (like Nginx) or a content delivery network (like Cloudflare) sitting in front of the actual application server. That front-facing layer handles incoming traffic and passes requests along to wherever the real processing happens.
When the backend server sends back something the proxy can’t parse, or doesn’t send anything usable at all, the proxy has no choice but to report a 502. It’s the middleman shrugging and saying “I asked, and I didn’t get a workable answer back.”
Common Causes of a 502 Bad Gateway Error
A few things tend to trigger this:
- Server overload. Traffic spikes can overwhelm an application server, especially on shared hosting plans with limited resources.
- Backend process crashes. PHP-FPM, a Node.js process, or another application layer can crash or hang, leaving the proxy with nothing to relay.
- Bad code deployments. A recent plugin update, theme change, or code push introduced a bug that’s breaking requests.
- Overly aggressive firewall or security rules. Some WAF configurations mistake normal traffic for an attack and block it.
- DNS issues. If DNS records point to the wrong server, or haven’t fully propagated after a migration, the gateway may be talking to the wrong place or nowhere at all.
- CDN or proxy hiccups. Services like Cloudflare occasionally run into their own connectivity issues reaching your origin server.
- Network problems between servers. Even a brief drop in connectivity between the proxy and the backend can trigger this.
Is It Just You, or Is the Site Actually Down?
Before assuming the worst, rule out your own connection. A 502 that only shows up on your device could be a local caching issue rather than an actual server problem. A tool like CheckSiteStatus’s website down checker tells you whether a site is down for everyone or just misbehaving on your end, which saves you from troubleshooting a problem that isn’t actually yours.
How to Fix 502 Bad Gateway as a Visitor
If you’re just trying to reach a site and keep hitting this wall, work through these in order:
- Refresh the page. Obvious, but 502 errors are often brief blips that resolve within seconds.
- Clear your browser cache and cookies. Old cached data can sometimes conflict with a site’s current server response.
- Try a different browser or an incognito window. This rules out extensions or local settings as the culprit.
- Restart your router. Occasionally the problem sits between you and your ISP, not between the site and its server.
- Disable any VPN or proxy you’re running. Some VPNs route traffic through servers that trigger gateway errors on certain sites.
- Wait a few minutes and try again. If the site is dealing with a traffic spike or a backend restart, it may resolve on its own.
- Check whether the outage is widespread with a real-time outage checker before assuming your device is at fault.
How to Fix 502 Bad Gateway as a Website Owner
If it’s your own site throwing the error, the fix depends on where the breakdown actually happened.
Check your server error logs first. Nginx, Apache, and application logs will usually show exactly which upstream request failed and why. This is almost always faster than guessing.
Restart the backend service. If PHP-FPM, a Node process, or another application layer has crashed or hung, restarting it often clears the error immediately.
Review recent changes. If the error started right after a plugin update, theme change, or code deployment, roll that change back and test again.
Check your firewall and security rules. A WAF or security plugin might be blocking legitimate requests from your own server components, not just outside traffic.
Look at your CDN or reverse proxy status. If you use Cloudflare or something similar, check its status page. Sometimes the fault isn’t your server at all.
Verify DNS is pointing where it should. Especially after a server migration, records that haven’t fully propagated can send the gateway to the wrong destination.
Scale up resources if traffic is the issue. If your logs show the server was overwhelmed, you may need more memory, CPU, or a better hosting plan.
For an ongoing view of your server’s reachability, Check Server / Check Host can confirm whether your server responds from multiple locations, which is handy when a 502 only shows up for users in certain regions.
Preventing Future 502 Errors
The real fix is catching this before your visitors do. Setting up continuous uptime monitoring means you find out the moment your site starts throwing errors, instead of hearing about it from an angry email or a sudden drop in traffic. Pair that with regular log reviews and a habit of testing changes on staging before pushing to production, and 502 errors turn into a rare inconvenience instead of a recurring headache.
Usually not. It typically points to a problem on the server side, whether that’s the backend application, the proxy, or something in between. Occasionally, a local network or browser issue can produce something that looks similar, which is why it’s worth ruling out your own connection first.
It varies. Many clear up within a few minutes if they’re caused by a brief server hiccup or a traffic spike. If the underlying issue is a crashed process or a bad deployment, it can stick around until someone fixes it on the server side.
Sometimes. If your browser cached an old, broken response, clearing it can force a fresh request that succeeds. It won’t help if the server itself is genuinely down, but it’s a quick, harmless step worth trying first.
A 502 means the gateway got an invalid response from the upstream server. A 503 means the server is up but temporarily unable to handle the request, often due to maintenance or overload. They look similar to visitors but point to different problems behind the scenes.
Yes. If Cloudflare or a similar CDN can’t get a valid response from your origin server, it displays a 502 on its own branded error page. Checking your CDN’s status page and your origin server’s health separately helps narrow down where the actual fault sits.