@http · HTTP status codes, explained HTTP/1.1 502 Bad Gateway ━━━━━━━━━━━━━━━━━━━━━━━━ 5xx · Server error A proxy got an invalid response from upstream. WHAT IT MEANS ──────────────────────────────────────────────────────────── A gateway or proxy, such as nginx, a load balancer or a CDN, got an invalid response from the server behind it, or no response at all. The proxy itself is fine; the problem is upstream. WHY YOU'RE SEEING IT ───────────────────────────────────────────────────── → The app server crashed, restarted or isn't running. → The proxy points to the wrong host or port. → The upstream closed the connection early or sent malformed headers. → TLS problems between the proxy and the origin. HOW TO FIX IT ──────────────────────────────────────────────────────────── → Check that the upstream is running and reachable from the proxy. → Read the proxy's error log; nginx says why, e.g. "connection refused" or "upstream prematurely closed". → Clients can retry with backoff, since 502s are often brief during deploys. EXAMPLE RESPONSE ───────────────────────────────────────────────────────── HTTP/1.1 502 Bad Gateway Content-Type: text/html  

502 Bad Gateway

 related 504 Gateway Timeout   503 Service Unavailable   500 Internal Server Error spec RFC 9110 §15.6.3 https://www.rfc-editor.org/rfc/rfc9110#section-15.6.3 web https://athttp.com/502 ← curl athttp.com/501 curl athttp.com/503 →