← Back to Home (Checker) View All Guides
Server Error

What Is a 502 Bad Gateway Error (and How to Fix It)

A 502 Bad Gateway error is another 5xx server error, but it's more specific. It means your request was successfully received by a "gateway" server (like a CDN, proxy, or load balancer), but that server received an invalid or "bad" response from the main "origin" server (your web host).

What Does "Bad Gateway" Mean?

Imagine you call a company's front desk (the gateway). You ask to be transferred to the sales department (the origin server). The front desk tries to connect you, but the sales department's line is broken or sends back a garbled message. The front desk then hangs up and tells you they got a bad response.

This is almost always a server-to-server communication problem, heavily common if you use a proxy service like Cloudflare.

How to Fix 502 Errors

1. Check if Your Origin Server (Host) is Down

Your main web hosting server might be offline, rebooting, or experiencing an issue (like a 500 or 503 error). The gateway tries to get your site, gets the error, and shows a 502 to the user.

  • How to fix: Check your server's status. If you use Cloudflare, you can "pause" it to see the real error.

2. Check Server Overloads

Just like a 503 error, your origin server might be overloaded with traffic or a runaway script. The gateway's request times out while waiting for a response.

  • How to fix: Check your server's resource usage (CPU, RAM) in your hosting panel. Look for traffic spikes.

3. Check Your Firewall

Your server's firewall (or a security plugin) might be mistakenly blocking requests from your gateway service (CDN).

  • How to fix: You must "whitelist" the IP ranges of your CDN. Add them to your firewall's "allow list" so it never blocks them.