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 <h1>502 Bad Gateway</h1>