HTTP Errors

What Is the 502 Status Code? (Bad Gateway)

On this page

HTTP 502 Bad Gateway means one server, acting as a middleman, got a broken reply from another server behind it. Many websites sit behind a gateway or proxy — a front-door server that forwards your request to the real "upstream" server that does the work. A 502 means that front door reached the upstream server but got back garbage it couldn't use. Because it's a 5xx (server-side) error, the fault is on their end, not yours, and it's usually temporary. You'll also see it written "HTTP 502" or just "502 error" / "502 status code."

Quick facts

Status code502
MeaningBad Gateway
Category5xx Server Error
Common causes (scraping)Flaky proxy, overloaded/down origin, CDN can't reach backend
Right responseFix the request / retry with backoff; for disguised blocks use a real-browser unblock

What a 502 Bad Gateway means

Think of the gateway or proxy as a receptionist who passes your request to a back office. A 502 means the receptionist got the message through to the back office (the "upstream" server) but the reply came back broken or unreadable. So the failure happens between the edge (the front-facing server) and the origin (the real backend) — not in your request. Because it's a 5xx error, it's a server-side problem and usually clears up on its own.

Why scrapers see 502

When scraping, a 502 usually points to something flaky on the path to the site: an unreliable proxy, an origin server that's overloaded, or a CDN (content delivery network — the cache layer that fronts many sites) that can't reach the backend. It can also show up briefly when an anti-bot edge mishandles or drops a request it finds suspicious. Unlike a 403 (which is a hard "access denied"), a 502 is generally worth retrying.

How to fix a 502 error

Retry with exponential backoff and jitter — that means waiting a bit longer between each attempt and adding a small random delay so retries don't all hit at once. Most 502s clear on their own. If they persist, the gateway between you and the origin is the real problem: swap to a more reliable proxy pool, lower concurrency (fewer requests at once) so you're not overwhelming a fragile origin, and check whether your proxy provider — not the target site — is the one returning the 502. Persistent 502s that only appear on protected URLs can mean an edge is dropping you; in that case a real-browser unblock flow via Web Access API is more stable.

Related terms

Concept map

How 502 Status Code (502 Bad Gateway) connects

The terms most directly tied to this one. Hover a node to see its neighbours, click to preview, drag to rearrange.

0 terms · 0 connections
You are here · HTTP Errors
Building map…

Frequently asked questions

Is 502 a client or server error?

It's a server-side error (the 5xx family). The problem is between servers — the front-door gateway and the backend it talks to — not in your request.

Does a 502 mean I'm blocked when scraping?

Usually not. A 502 is typically a temporary, server-side hiccup, so it's worth retrying. It can occasionally line up with edge blocking, but it isn't a clear block signal the way a 403 is.

How do I fix a 502 error?

The cause is a gateway or proxy getting a broken reply from the upstream server, so the fix targets that path. Retry with backoff (waiting longer between attempts), and use reliable proxy and request infrastructure.

What's the difference between 502 and 503?

A 502 Bad Gateway means an upstream server handed the gateway a broken response. A 503 Service Unavailable means the server itself is up but can't handle the request right now — usually due to overload or maintenance. Both are 5xx (server-side) errors and are usually temporary.

Last updated: 2026-05-31