502 Bad Gateway
The 502 (Bad Gateway) status code indicates the message was forwarded to an inbound server (usually the origin server), which produced an invalid response.
Writing responses (servers)
This status code is only used by intermediate nodes when they received an invalid HTTP response from the origin server, and cannot pass it through. For example, the node tries to contact the origin, but receives a response in an unknown protocol, or an unsupported version of HTTP.
Intermediate servers may wish to provide a debugging mode, which shows the response it received, and why it could not be parsed.
See also: 504 Gateway Timeout
If the origin could not be contacted at all, or no response at all was generated within a reasonable time, see 504 Gateway Timeout.
Reading responses (clients)
Clients using a proxy may try to use a different proxy, or issue the request directly to the origin, if the problem is at the proxy. Otherwise, clients may try to re-request at a later time; a system administrator must correct the configuration of the proxy, gateway, or origin.
Users may try to use TRACE with Max-Forwards to isolate the problematic node.
Overview table
- Name
- 502
- Message
- 502 Bad Gateway
- Description
- An intermediate server received an invalid response from an inbound server.
- Specification
- RFC 7231: HTTP/1.1 Semantics and Content ยง6.6.3. 502 Bad Gateway
Example
HTTP/1.0 503 Bad Gateway
Content-Type: text/plain
The received upstream response from <http://origin.example.com/search>
could not be parsed from line 5.
Request id: 30