Developer

Encoders, converters & dev utilities

12 tools
Developer · HTTP Status Codes Reference

502 Bad Gateway

HTTP 502 Bad Gateway. A server acting as a gateway or proxy received an invalid response from the upstream server it tried to reach. When to use it: Returned by proxies/load balancers when the upstream (origin/app) sends a malformed or no response. It is a server-error (5xx) status, which means the request was valid but the server failed to fulfil it. (Reference: RFC 9110 §15.6.3.)

Quick answer

A server acting as a gateway or proxy received an invalid response from the upstream server it tried to reach.

  • When to use: Returned by proxies/load balancers when the upstream (origin/app) sends a malformed or no response.
  • How to handle: Check the health of the upstream service and the proxy configuration; ensure the origin is running and reachable.
  • Reference: RFC 9110 §15.6.3
  • Category: 5xx Server Error
Open the full HTTP Status Codes Reference

Frequently asked questions

What does HTTP 502 mean?

HTTP 502 Bad Gateway: A server acting as a gateway or proxy received an invalid response from the upstream server it tried to reach. It is a server-error (5xx) status, which means the request was valid but the server failed to fulfil it. It is defined in RFC 9110 §15.6.3.

What is the difference between 502 and 504?

Both are proxy/gateway errors. 502 Bad Gateway means the gateway reached the upstream server but got an invalid or malformed response. 504 Gateway Timeout means the gateway reached the upstream but did not receive a response in time. Roughly: 502 = the upstream replied badly, 504 = the upstream was too slow. Check the upstream service’s health and the proxy configuration to resolve either.

Related HTTP Status Codes Reference pages