NEWStandard createTask and in.php APIs. Change the address and you are connected.View API docs
GATESOLVER

Errors and troubleshooting

Why do I get 502 Bad Gateway through a proxy?

A 502 means some gateway in the chain received an invalid reply, or none, from the next server, and with a proxy in the path that gateway is often the proxy itself.

What 502 means in a proxy chain

502 Bad Gateway is sent by a server that acts as an intermediary: a proxy, a load balancer or a CDN edge. It means "I asked the next server and got garbage, or the connection broke". With a scraping proxy in the path, there are at least two possible intermediaries: your proxy provider's gateway, which forwards to an exit node, and the site's own CDN or reverse proxy. Finding out which one sent the 502 is the first step.

Who sent it?

  • Look at the body and headers. A provider branded error page, or a short text body from the proxy software, points at the proxy. A page from the site's CDN, such as a Cloudflare 502 page with a Ray ID, points at the site's side.
  • Try without the proxy. If the same URL works directly from your server, the site is fine and the proxy path is at fault.
  • Try another exit IP. If a different IP from the same pool works, one exit node is broken or blocked.
  • Try another site through the proxy. If every site fails, the proxy gateway or your plan is the issue.
def who_failed(direct_status, proxied_status, other_site_proxied_status):
    if proxied_status != 502:
        return "no 502 now, transient"
    if direct_status == 502:
        return "target site or its CDN"
    if other_site_proxied_status == 502:
        return "proxy gateway or account"
    return "this target through this proxy: exit node, block or TLS issue"

Common causes on the proxy side

  • Exit node went offline. Residential exits are real devices that disconnect. The gateway reports 502 when the chosen device drops mid-request.
  • Target refused the exit IP. Some providers translate a reset or refused connection from the target into a 502.
  • TLS problems. A proxy that inspects traffic, or a target with an unusual certificate chain, can fail the handshake and return 502.
  • Provider restrictions. Some providers block certain domains and answer with a 502 or 403 when you request them.

Common causes on the site side

The site's own gateway returns 502 when its application server crashes, restarts or times out in a particular way. These usually clear within seconds to minutes and affect all visitors, not only you. Check the site in a normal browser. Cloudflare has its own codes for origin trouble; error 522 and 524 are related cases.

What to do in code

Treat 502 as retryable, with a short backoff. With a rotating proxy, retry on a new exit IP, which fixes most proxy-side 502s. Limit retries to three or four, then mark the URL for later. Track 502 rates per proxy and per domain: a spike for one domain suggests a site outage, a spike everywhere suggests a proxy problem. The guide to exponential backoff covers the timing.

Effects on CAPTCHA tasks

A proxy task whose proxy keeps returning 502 cannot load the page, so the task fails and is not charged. If you see repeated failures on proxy tasks while proxyless ones work, test the proxy with the checks in how to test a proxy. For token widgets, you can also switch to the proxyless type so the solve no longer depends on your proxy at all.

When to contact the provider

If 502s persist across many exit IPs and many target sites while your plan is active, the gateway may be degraded. Collect a few timestamps, target URLs and the full error body, and send them to your proxy provider. Those details shorten the conversation considerably.

Common questions

Is a 502 my fault or the site's?

Either. Compare a direct request with a proxied one and try another site through the proxy to tell them apart.

Should I retry a 502?

Yes, a few times with a short backoff, preferably on a new exit IP when you use a rotating proxy.

Why do residential proxies give more 502s?

Their exit nodes are consumer devices that disconnect without warning, which the gateway reports as 502.

Is 502 the same as 504?

No. 502 is an invalid or broken reply from upstream; 504 means the upstream did not reply in time.

Does a 502 on a proxy task cost anything?

No. If the solver cannot load the page through your proxy, the task fails and is free.

Keep reading