- Home
- Tools
- Developer Tools
- HTTP Status Codes
- 502 Bad Gateway
502 Bad Gateway
A proxy or gateway got no valid answer from the server behind it. Usually the site's own application is down or crashing.
- Class
- 5xx Server error. The request may have been fine, but the server failed to fulfil it.
- Defined in
- RFC 9110
What causes it
In any setup with one server in front of another: a reverse proxy such as nginx, a load balancer, a CDN. The front server passed the request on and got a refused connection, a connection that was cut off halfway, or something that isn't HTTP. Typical causes are an application that crashed or is restarting, one that listens on another port or socket than the proxy expects, and one that ran out of memory in the middle of a request.
What to do about it
As a visitor: wait a moment and reload. A deploy or a restart is often over in seconds.
As the owner: check that the application is running, and then read the error log of the proxy, which says what happened to the connection. In nginx that is a line such as "connection refused" or "upstream prematurely closed connection".
Not to be confused with
| 504 Gateway Timeout | The backend was reached and did not answer in time. |
|---|---|
| 503 Service Unavailable | The server says itself that it can't take requests now. |
| 500 Internal Server Error | The application did answer, with an error. |
How Google treats it
Google slows down its crawling for a site that returns 502, and drops pages that keep doing so.
All codes are on the list of HTTP status codes, which can be searched by number and by word.