502 Bad Gateway: What It Means and How to Fix It (Visitors and Site Owners)
You click a link and get a plain white page that says 502 Bad Gateway. Sometimes it’s dressed up with a logo, sometimes it’s just a line of text and the word nginx or cloudflare underneath. Either way, the page you wanted isn’t there.
Here’s what’s going on. Most websites don’t run on a single machine. Your request hits a front-door server first (a gateway, proxy or CDN like Cloudflare), and that server passes it along to the server that actually builds the page. A 502 means the front door asked the back-end server for the page and got garbage back, or nothing usable at all.
So is it your fault? Almost never. A 502 is a server-side error. But there are a few things on your end worth ruling out.
What causes a 502
- The website’s main server crashed or is overloaded. Traffic spikes and runaway code are classic triggers.
- The server is restarting or being updated.
- A firewall or security rule blocks traffic between the gateway and the back-end server.
- Timeouts because a page takes too long to generate.
- DNS changes that haven’t finished spreading, so the gateway points at the wrong server.
- Rarely, your own network, through bad DNS, a proxy or a VPN.
If you’re just visiting the site
1. Wait a minute and reload
Most 502s are short-lived. Give it 30 to 60 seconds and press F5. If the site was mid-restart, it’ll come back.
2. Check if it’s down for everyone
Search the site’s name plus “down” or check a status site like Downdetector. If lots of people are reporting it, there’s nothing to fix on your end.
3. Try another browser or device
Open the page in an incognito window, a different browser, or your phone on mobile data. If it works there, the issue is local to your computer or network.
4. Clear your cache and flush DNS
A cached error page or an old DNS answer can keep you stuck after the site is back. Clear your browser cache, then follow the DNS flush steps in our DNS_PROBE_FINISHED_NXDOMAIN guide.
5. Turn off VPNs and proxies
Some VPN servers get flagged or rate-limited by websites, which can show up as a 502. Disconnect and try again.
6. Restart your router
Unplug it for 30 seconds. It’s a long shot for a 502, but it costs nothing.
If it’s your website
Now it’s on you. Here’s where to look, roughly in order.
- Check your hosting status page. Your host may already know.
- Look at your server error logs. Nginx, Apache and PHP logs usually name the problem.
- Restart PHP-FPM or your app server. A crashed process is the most common cause.
- Disable recently added plugins or code. On WordPress, rename the plugins folder by FTP or your host’s file manager to switch them all off at once.
- Raise timeouts if long-running pages are timing out between the proxy and the app.
- Check your CDN settings. If you use Cloudflare, make sure its IP ranges aren’t blocked by your server firewall.
- Look at resource limits. If you’re hitting CPU or memory caps, it may be time to upgrade your plan.
502 vs other server errors
| Error | Plain-English meaning |
|---|---|
| 500 Internal Server Error | The server broke while building the page |
| 502 Bad Gateway | A server got a bad answer from another server |
| 503 Service Unavailable | The server is overloaded or down for maintenance |
| 504 Gateway Timeout | A server waited too long for another server to answer |
Does a 502 hurt SEO?
A brief 502 won’t. Google retries pages later. But if search engines keep hitting 502s for hours or days, they’ll crawl your site less and can drop pages from results. If you run the site, fix recurring 502s quickly and set up uptime monitoring so you hear about them before your visitors do.
Our take
As a visitor, a 502 is the internet’s way of saying “not you, them.” Reload once, check if the site is down for everyone, and move on. As a site owner, start with your logs and recently changed plugins. That’s where the answer usually is.
FAQ
What does 502 Bad Gateway mean?
A server acting as a gateway or proxy got an invalid response from the server behind it, so it couldn’t give you the page.
Is a 502 error my fault?
Rarely. It’s almost always a server-side problem. Rule out your VPN, cache and DNS, then wait.
How long does a 502 error last?
Often a few seconds to a few minutes. Longer outages mean the site owner needs to fix something.
Can my router cause a 502?
It’s unlikely but possible through bad DNS or proxy settings. Restarting the router is a cheap test.
How do I fix a 502 on WordPress?
Check your host’s status, restart PHP, review error logs, and disable recently added plugins or themes.