Explain HTTP 502, 503, and 504 — what causes each and how do you debug them?
Quick Answer
502 Bad Gateway: the proxy got an invalid/failed response from the backend. 503 Service Unavailable: the service is temporarily down or overloaded. 504 Gateway Timeout: the backend did not respond in time. All three are edge/proxy-to-backend problems.
Detailed Answer
502 → the backend crashed, returned garbage, or the proxy config points nowhere: check backend health and proxy logs. 503 → the app is down, overloaded, or in maintenance (or no healthy upstreams behind the LB): check replicas/health checks and scale. 504 → the backend is too slow: raise timeouts as a stopgap but fix the slow dependency. Correlate LB/ingress logs with backend logs by request ID.
Interview Tip
Anchor each to the proxy↔backend relationship: 502 bad response, 503 unavailable, 504 too slow — then give the debug step.