All HTTP status codes

HTTP 502 Bad Gateway

Server Error

A 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

  1. Check whether the upstream process is running and healthy

  2. Verify proxy upstream configuration and security-group/firewall paths

  3. Inspect upstream logs — the proxy log only says 'bad response'

  4. Add health checks so the LB stops routing to dead instances

Want to explore status codes interactively? Try the free HTTP Status Code Reference — search, categories and example responses, right in your browser.