HTTP status codes / 5xx — Server errors

502 Bad Gateway

In one sentence

A proxy got an invalid response from the upstream server.

What it means

A gateway (load balancer, reverse proxy, CDN) talked to the origin and received garbage: connection refused, crashed worker, malformed response. The proxy is healthy; the thing behind it is not.

Common causes

Reproduce it in cURL

curl -i https://httpbin.org/status/502

Same request, no terminal: paste this into the cURL converter for native code, or straight into ReqPad on your phone.

How to debug it

Check origin health and the proxy’s upstream error logs; after deploys, 502s usually mean the app process is not listening yet (or died).

Server-side note: Check origin health first, then the proxy error log (nginx: upstream prematurely closed). Post-deploy 502s = app not up yet; add readiness checks.

The fastest way to pin down a 502 is to reproduce the exact request and inspect what actually went over the wire — status, headers, timing and body, without your app code in the way. That is what an API client is for; ReqPad does it from your phone, with every request saved to history.

Related codes

500 Internal Server Error · 501 Not Implemented · 503 Service Unavailable · 504 Gateway Timeout · 505 HTTP Version Not Supported · 506 Variant Also Negotiates — or the full reference.

Reproduce that 502 in 10 seconds.

Build the request, send it, read status + headers + timing — on your iPhone. Free to start.