5xx Server error

HTTP 502 Bad Gateway

A gateway or proxy received an invalid response from the upstream server.

502 Bad Gateway means a server acting as a gateway or proxy, such as nginx, a load balancer or a CDN, got an invalid response or no response from the upstream server behind it.

HTTP/1.1 502 Bad Gateway

Common causes

  • The application server crashed, is restarting or is not listening on the expected port.
  • The proxy points at the wrong upstream address.
  • The upstream closed the connection or sent a malformed response.

How to fix it

  • Check that the application process is running and reachable from the proxy.
  • Read the proxy's error log (for nginx, error.log shows 'connect() failed' or 'upstream prematurely closed').
  • As a visitor, wait a moment and reload: 502s during deploys usually clear quickly.

Related status codes

Other status codes

1xx Informational

2xx Success

3xx Redirection

5xx Server error

Search all HTTP status codes