HTTP 502 Bad Gateway
Server ErrorA gateway/reverse proxy got an invalid response from the upstream server — the proxy is fine, the thing behind it isn't answering properly.
Defined in RFC 9110
Common causes
- Upstream app crashed, still booting, or listening on the wrong port
- Upstream response malformed or connection reset
- Wrong upstream host/port in proxy config (nginx upstream, load balancer target group)
How to fix it
Check whether the upstream process is running and healthy
Verify proxy upstream configuration and security-group/firewall paths
Inspect upstream logs — the proxy log only says 'bad response'
Add health checks so the LB stops routing to dead instances
Related status codes
The server is temporarily unable to handle the request — overloaded, in maintenance, or deliberately shedding load. Retry-After may say when to come back.
504 Gateway TimeoutA gateway/proxy didn't get a response from the upstream in time. The upstream may still be processing — the proxy just gave up waiting.
500 Internal Server ErrorA generic 'something broke on the server' — an unhandled exception or misconfiguration with no more specific status to report.
Want to explore status codes interactively? Try the free HTTP Status Code Reference — search, categories and example responses, right in your browser.