Writing

502 Bad Gateway

Published 17 September 2026

A 502 bad gateway is two of somebody else's servers failing to talk to each other. Almost none of it is about you, and the error itself is the proof, because a server had to receive your request and compose a reply in order for you to be reading the number at all.

What the words mean

A gateway is a machine in the middle: a reverse proxy, a load balancer, a CDN edge, an API gateway. It does not generate the page you asked for. It takes your request, hands it to a backend server behind it, and relays whatever comes back.

Bad gateway means the answer it got back was unusable. The backend either replied with something that was not valid HTTP, or closed the connection mid-sentence, or was not there to reply at all. The gateway, having nothing sensible to relay, tells you 502.

So the sentence to hold onto is: the front server worked well enough to answer you, and the server behind it did not.

Why this cannot be your network

Every HTTP status code is evidence of a completed round trip. For a 502 to appear on your screen, the name resolved, a TCP connection opened, TLS negotiated if it was https, your request was delivered, and a response came back. All five worked.

Had your network been the problem, you would have no status code: a refused connection, a timeout with no reply, or a DNS failure. Those look and behave differently, and none of them produce a numbered error page.

Leg of the journeyWhoseWorked?
You → their gatewayYou and the internetYes
Their gateway → their backendThemNo: this is the 502
Their gateway → youYou and the internetYes

502 or 504? They are not the same

Both come from the gateway, and the difference tells you what to look for.

Nonsense versus silence. A 502 usually means something is down or crashing; a 504 usually means something is slow.

If you own the server

Work backwards from the gateway. It is reporting honestly, so the fault is behind it.

If you do not own it

Get the verdict in one request. The HTTP status checker fetches the URL, follows the redirect chain, and states whether the fault is yours, theirs or actually the network, and surfaces the headers that change the answer, including cf-ray and retry-after.

Check a URL

What a 502 is never

The one honest exception: if you sit behind a corporate proxy, that proxy is a gateway too, and it can generate a 502 of its own about a backend it could not reach. The tell is the error page: it will look like your company's, not the site's. That case is worth raising internally, and it is the only version of this where the network team is the right audience.