Skip to content
Get Started
G2G2
4.7/5
Excellent
Trustpilot

What Is a 502 Bad Gateway Error?

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.

  • Session Control
  • High Speed
  • Privacy First
Best fit for 502 Bad GatewayRotating Residential Proxiesfrom$0.63/GB
how it works

How a 502 happens

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:

  • 502 Bad Gateway

    This term
    Means
    The upstream answered badly or hung up
    Typical cause
    Crashed app server, reset connection, bad config
  • 2

    503 Service Unavailable

    Means
    The server is overloaded or down for maintenance
    Typical cause
    Traffic spikes, deploys, deliberate throttling
  • 3

    504 Gateway Timeout

    Means
    The upstream did not answer in time
    Typical cause
    Slow origin, network trouble, long queries
why it matters

Why proxy users see 502s

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.

502 Bad Gateway: what it means for you
  • Retry with backoff. Most 502s are short-lived, from a restarting server or a rotating exit that went offline mid-request.
  • Test the site without the proxy. If it fails there too, the website is down and no proxy setting will help.
  • Check the proxy host, port and protocol. Sending HTTPS-proxy or SOCKS traffic to an HTTP proxy port can produce gateway errors.
  • On rotating residential, request a new session: a home device behind the exit may have disconnected.
A 502 from the proxy, during CONNECTShell
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 502

Rotating residential proxies from $0.63/GB

The CleanProxies proxy that fits best here, with a $4.99 trial to test it first.

Guides from the blog

Setup guides and best practices from the CleanProxies blog.

Get the latest insightsAll Blogs

Related terms

Terms that come up alongside 502 Bad Gateway.

All glossary terms

502 Bad Gateway FAQs

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.

Got more questions?All FAQs