← All status codes
502

Bad Gateway

A server in the middle, like a load balancer, reverse proxy or CDN, tried to pass your request on to the server behind it and got back something it couldn't use. Either the upstream server didn't answer properly, or the connection closed before a full response came back.

So the proxy is up, and the thing behind it isn't working. That's the useful part of a 502: it tells you where to look.

What we see on Larm

Failed HTTP checks on Larm from 9 October to 8 November 2026, across about 130 monitors.

36 of the roughly 130 HTTP monitors on Larm got at least one 502 in this period. No other status code hit as many monitors. Next were 503 (19 monitors) and 500 (12). The median time to first byte on a 502 was 311 ms, so most came back quickly. That usually means the app refused or dropped the connection rather than hanging. If the proxy had given up waiting, you'd normally see a 504 instead.

COMMON CAUSES

The app process crashed or isn't running, so the proxy's connection is refused
The app is restarting during a deploy and the proxy sends traffic to it before it's ready
The app closed the connection before sending a full response, for example after running out of memory mid-request
The proxy points at the wrong port, or uses HTTP where the app expects HTTPS, or the other way around

HOW TO FIX IT

Check that the app process is running and read its logs from around the time of the 502
Check the proxy's error log. Nginx records the reason, for example connect() failed (111: Connection refused) or upstream prematurely closed connection
If the 502s line up with deploys, the proxy is routing to instances that aren't ready yet. Add a health check that has to pass before traffic is sent
Check memory. An app killed by the OOM killer looks like a crash to the proxy
Confirm the proxy points at the right host, port and protocol

What this means for monitoring

A single 502 from one location is often a restart that's over a few seconds later. A 502 that lasts across several checks and locations means the app is down behind a proxy that's still working. Larm only marks a monitor down when a majority of probes see the failure and it lasts past the confirmation window, so short restarts don't page you.

Related status codes

5xx Server Error

Get alerted when your endpoints return unexpected status codes.

Larm checks your HTTP endpoints from multiple global locations and alerts you when they return status codes outside your expected range.