server error RFC 9110
HTTP 502 Bad Gateway
A gateway or proxy received an invalid response from the upstream server.
What it means
The server you contacted (a proxy, load balancer, CDN, or API gateway) tried to forward your request to another server and got back something it couldn't parse. Common when the app server crashed mid-response, when nginx can't reach the upstream, or when the upstream returns nonsense.
When servers send it
- •Nginx couldn't connect to upstream Node process
- •Cloudflare couldn't reach the origin
- •AWS ALB got a malformed response from EC2
- •Application server crashed during response generation
What the client does
Retries after a delay. Idempotent requests are safe; POSTs need care.
Common causes
- •Upstream server is down
- •Upstream server crashed while handling the request
- •Upstream is overloaded and closing connections
- •Network issue between proxy and upstream
How to fix it
- 1.Check upstream server health
- 2.Check the proxy logs for the specific upstream error
- 3.For Cloudflare 502s: check origin health
- 4.Increase upstream timeout if the upstream is just slow
Similar codes
500 Internal Server Error server error
Something went wrong on the server side — usually an unhandled exception.
503 Service Unavailable server error
Server is temporarily unable to handle the request — overloaded or down for maintenance.
504 Gateway Timeout server error
A gateway or proxy timed out waiting for a response from the upstream server.
501 Not Implemented server error
Server doesn't support the functionality required to fulfill the request.
← All HTTP status codes · HTTP status cheat sheet · HTTP headers reference