502 Bad Gateway
- Means
- The upstream answered badly or hung up
- Typical cause
- Crashed app server, reset connection, bad config
502 Bad Gateway is the HTTP status a gateway or proxy returns when it received an invalid response, or none it could use, from the server it forwards to. The fault is upstream of whoever sent the 502, not in your request.
Modern websites sit behind layers: a CDN, a load balancer or reverse proxy, then the application server. If any layer gets a broken, reset or empty answer from the next one, it returns 502. RFC 9110 separates it from its neighbours:
With a forward proxy there are two places a 502 can come from, and they need opposite fixes. If the proxy could not reach the site or the exit dropped the connection, the 502 arrives while the tunnel is being opened. If the tunnel opened and the site's own CDN failed, the 502 arrives inside it, usually as a branded HTML error page.
CleanProxies rotating residential proxies let you rotate on every request or hold a sticky session; on a 502, retry on a fresh session. The proxy errors guide covers 407, 403 and 429 too.
curl -x http://USERNAME:PASSWORD@HOST:PORT https://example.com
# curl: (56) CONNECT tunnel failed, response 502
# A 502 from the site arrives after the tunnel opens:
# < HTTP/2 502The CleanProxies proxy that fits best here, with a $4.99 trial to test it first.
Rotating or sticky residential IPs in 190+ countries, with data that never expires.
Residential IPs in 190+ countries with country, state and city targeting. Rotate on every request or hold a sticky session for up to 24 hours; GB never expire.
Setup guides and best practices from the CleanProxies blog.
Terms that come up alongside 502 Bad Gateway.
Straight answers about 502 Bad Gateway.
A server acting as a gateway or proxy got an invalid response from the server behind it. The problem is between servers, not in your browser or request.