Guide
What Does 502 Bad Gateway Mean? (Causes & How to Fix It)
7 min read · Updated August 7, 2026
You tried to open a page and got a blunt message: 502 Bad Gateway. It's one of the most common server errors on the web, and the good news is it's usually temporary and not caused by anything you did. Here's exactly what a 502 means, why it happens, and how to fix it — whether you're a visitor who just wants the page to load or the owner of the site throwing the error.
What a 502 Bad Gateway error actually means
A 502 is a server-side status code (the 5xx family always means the problem is on the server, not your device). Specifically, it means one server, acting as a gateway or proxy, received an invalid response from another server it was relying on to fulfill your request. Modern sites rarely run on a single machine — a request usually passes through a load balancer, reverse proxy, or CDN before reaching the application server behind it. When that upstream server replies with something broken, empty, or not at all, the front-facing server gives up and returns a 502.
In plain terms: the site is reachable — it answered you — but the machine it depends on to actually build the page didn't cooperate. That's different from a 404 (page not found) or a 503 (server temporarily unavailable or in maintenance).
The most common causes of a 502
The upstream server crashed or is overloaded. The most frequent cause. If the application or backend server behind the proxy is down, stalled, or buried under traffic, it can't return a valid response — so the gateway serves a 502.
A bad deploy or a code error. A broken release, a crashed process, or a script that errors out can stop the backend from responding correctly.
Server timeouts. If the backend takes too long to respond, the proxy times out the connection and returns a 502 rather than waiting forever.
CDN or proxy misconfiguration. Services like Cloudflare sit in front of your site; a misconfigured origin, firewall rule, or DNS setting can break the link between the CDN and your actual server.
Resource limits on cheap hosting. Budget shared hosting caps memory and processes. Hit the ceiling and the backend gets killed, producing intermittent 502s.
If you're a visitor: how to fix a 502
A 502 is on the site's end, so your options are limited — but a few are worth trying:
Refresh after a moment. Because 502s are often momentary, waiting 30 seconds and reloading fixes it much of the time.
Confirm it's the site, not you. Run the address through WebsitePulseCheck. If our server-side check also sees the error, it's the site — all you can do is wait. If we see it as up, the problem may be local to your network or a cached error page.
Clear your cache or try another network. Reload without cache (Ctrl+Shift+R / Cmd+Shift+R), or switch to mobile data to rule out a local hiccup. A related "this site can't be reached" message is a different problem — see our guide on fixing connection errors.
If you own the site: how to fix a 502
Check whether your backend is running. Confirm your application server (PHP-FPM, Node, etc.) is up and hasn't crashed. Restarting the backend service clears a surprising number of 502s.
Review recent changes. If the 502 started right after a deploy or plugin update, roll it back. A single bad release is one of the most common triggers.
Look at your logs and timeouts. Server and proxy logs usually point straight at the cause — an out-of-memory kill, a crashed worker, or a request that exceeded the gateway timeout. Raising timeouts or adding memory often helps.
Check your CDN/proxy and origin. If you use Cloudflare or similar, confirm the origin server is reachable and firewall rules aren't blocking it.
Upgrade underpowered hosting. If 502s keep appearing under normal traffic, your plan is simply too small. Moving to hosting with more memory, better process management, and room to scale is the permanent fix — see the recommended hosts below.
Catch 502s before your visitors do
The worst way to learn about a 502 is a customer telling you the site is broken. Set up uptime monitoring so you're alerted within minutes of the first error — the tools recommended below check your site around the clock and message you the moment it starts returning a 502, so you can fix it before it costs you traffic or sales.
Tired of Downtime? Switch to Reliable Hosting
Disclosure: some links below are affiliate links. If you sign up through them we may earn a commission at no extra cost to you. We only list tools we believe are genuinely useful.
Hostinger
Best valueFast, beginner-friendly hosting with free SSL and a low starting price. A solid first move if your current host keeps going down.
Visit HostingerBluehost
Best for WordPressOfficially recommended by WordPress, with 1-click installs and 24/7 support. Popular for blogs and small business sites.
Visit BluehostSiteGround
Best supportExcellent uptime and support with strong performance features and daily backups. A reliable step up from budget hosts.
Visit SiteGroundCloudways
Best performanceManaged cloud hosting on top of providers like DigitalOcean and AWS — great when you need speed and room to scale.
Visit CloudwaysKinsta
Best premium managedPremium managed WordPress hosting on Google Cloud, with excellent uptime, speed, and expert support. The upgrade when reliability really matters.
Visit KinstaA2 Hosting
Best raw speedSpeed-focused hosting with Turbo servers and NVMe storage. A strong pick if slow load times are your main complaint.
Visit A2 Hosting