502
5xx Server ErrorBad Gateway
The server, acting as a gateway, got an invalid response upstream.
502 Bad Gateway means a server acting as a proxy or gateway (nginx, a load balancer, a CDN) got a broken or empty response from the upstream server it forwards to. The proxy is fine - whatever it talks to is down, crashed, or returned garbage. Look at the upstream app, not the proxy.
What 502 looks like on the wire
GET /api/products HTTP/1.1 Host: example.com HTTP/1.1 502 Bad Gateway Server: nginx Content-Type: text/html
About 5xx Server Error
The server failed to fulfill a valid request. The problem is on the server side, not the client.
How to fix 502 Bad Gateway
- Check whether the upstream app or service is actually running.
- Look at the upstream logs for a crash or out-of-memory kill.
- Verify the proxy points at the right host and port.
- If upstream is slow to boot, give it time or add a health check.
Where it's defined
502 Bad Gateway is defined in RFC 9110 §15.6.3. MDN's 502 reference covers browser behavior and examples.