What 502 means
Your request reached a proxy, load balancer or CDN (nginx, Cloudflare, AWS ALB), but the application server behind it crashed, refused the connection or returned garbage.
Common causes
- The app server crashed, is restarting, or isn't listening on the expected port.
- A deploy in progress.
- The upstream response was malformed or too large.
How to fix it
If you're calling an API
- Retry with backoff; 502s are often brief, during deploys or restarts.
- Check the provider's status page.
If you run the server
- Check the app is running and the proxy points at the right host and port; read the proxy's error log.
Should you retry?
Yes, with backoff.
Example response
HTTP/1.1 502 Bad Gateway
Content-Type: application/problem+json
{
"type": "about:blank",
"title": "Bad Gateway",
"status": 502,
"detail": "A proxy or gateway got an invalid response from the server behind it."
}Defined in: RFC 9110 (HTTP Semantics). 502 is a server error: the problem is on the server's side.
Debugging an API call? Convert your request with the cURL converter, check the response with the JSON formatter, or see whether the API is down on its status page.