502 Bad Gateway
The HTTP502 Bad Gatewayserver error response status code indicates that a server was acting as a gateway orproxy and that it received an invalid response from the upstream server.
This response is similar to a500 Internal Server Error response in the sense that it is a generic "catch-all" for server errors.The difference is that it is specific to the point in the request chain that the error has occurred.If the origin server sends a valid HTTP error response to the gateway, the response should be passed on to the client instead of a502 to make the failure reason transparent.If the proxy or gateway did not receive any HTTP response from the origin, it instead sends a504 Gateway Timeout to the client.
There are many causes of502 errors, and fixing such problems probably requires investigation by server owners or administrators.Exceptions are client networking errors, particularly if the service works for other visitors, and if clients use VPNs or other custom networking setups.In such cases, clients should check network settings, firewall setup, proxy settings, DNS configuration, etc.
In this article
Status
502 Bad GatewayExamples
>502 gateway error response
The following request tries to fetch a webpage, but receives a502 response in return.The response body contains a page describing the server state with a link to a support page for visitors.
GET /highlights HTTP/1.1Host: example.comUser-Agent: curl/8.6.0Accept: */*HTTP/1.1 502 Bad GatewayContent-Type: text/html;Content-Length: 123<!doctype html><html lang="en"><head> <title>502 Bad Gateway</title></head><body> <h1>Bad Gateway</h1> <p>The server was unable to complete your request. Please try again later.</p> <p>If this problem persists, please <a href="https://example.com/support">contact support</a>.</p></body></html>Specifications
| Specification |
|---|
| HTTP Semantics> # status.502> |