HTTP 502 Bad Gateway — What It Means & How to Fix It
Critical5xx server error
Overview
The HTTP 502 Bad Gateway status code indicates a server acting as a gateway or proxy received an invalid response from an upstream server.
Key Details
- This error occurs in multi-server architectures where a proxy or load balancer forwards requests.
- The gateway or proxy server itself is working, but the upstream server is not responding correctly.
- Common with nginx, Apache reverse proxies, CDNs, and load balancers.
- The upstream server may be down, overloaded, or returning malformed responses.
- It is often a transient error that resolves on its own.
Common Causes
- The upstream server is down or not responding.
- The upstream server returned a malformed or invalid response.
- Network issues between the proxy and the upstream server.
- The upstream server is overloaded and cannot handle the request.
Steps
- 1Retry the request after a short wait as it is often transient.
- 2Check if the upstream server is running and healthy.
- 3Review proxy and load balancer logs for detailed error information.
- 4Verify network connectivity between the proxy and upstream server.
- 5Check upstream server resource utilization (CPU, memory, connections).
Tags
httpserver-errorgatewayproxyupstream
Related Items
More in 5xx Server Error
http-500-internal-server-errorHTTP 500 Internal Server Error — What It Means & How to Fix It
Criticalhttp-501-not-implementedHTTP 501 Not Implemented — What It Means & How to Fix It
Criticalhttp-503-service-unavailableHTTP 503 Service Unavailable — What It Means & How to Fix It
Criticalhttp-504-gateway-timeoutHTTP 504 Gateway Timeout — What It Means & How to Fix It
Criticalhttp-505-http-version-not-supportedHTTP 505 HTTP Version Not Supported — What It Means & How to Fix It
Criticalhttp-506-variant-also-negotiatesHTTP 506 Variant Also Negotiates — What It Means & How to Fix It
CriticalFrequently Asked Questions
It means a server acting as a proxy or gateway received an invalid response from the upstream server it was forwarding the request to.