Skip to content
5xx Server Error Safe to retry

502 Bad Gateway

A proxy or gateway got an invalid response — or no response — from the server behind it.

What causes it

  • The upstream application crashed or is not listening on the expected port or socket.
  • The upstream returned a malformed response, or closed the connection early.
  • A deploy in progress: the old process stopped before the new one was ready.
  • A container health check failing so the load balancer has no healthy targets.

How to fix it

  • Check whether the upstream process is running and bound to the address the proxy expects (`ss -ltnp`).
  • Read the proxy error log — nginx logs the exact upstream address and failure reason.
  • For zero-downtime deploys, start the new process and confirm it is healthy before stopping the old one.

At a glance

Class
5xx Server Error
Reference
RFC 9110 §15.6.3
Standardised
Yes
Retry the request?
Yes, with backoff

Other 5xx server error codes

Back to the full HTTP status code reference