502 Bad Gateway
A proxy or gateway got an invalid response from the server behind it.
Reverse proxies (nginx, Envoy, Cloudflare, load balancers) answer 502 when the upstream application crashed, closed the connection or sent garbage. The proxy itself is fine; the app behind it is not.
In Kubernetes, 502s often appear during deployments when pods are terminated before the gateway stops sending traffic to them.
What to do
- Check that the upstream process is running and listening on the expected port.
- Compare proxy timeouts and keep-alive settings with the upstream's settings.
- Add a preStop delay so pods drain before they shut down.
Check a URL
See which status code a page returns right now with the header check.
Specification: RFC 9110 §15.6.3