What is a 502 error?
TL;DR
A 502 Bad Gateway means a proxy or load balancer forwarded your request to a server behind it and got back something it could not use: a malformed response, a closed connection, or nothing at all. The gateway is working. Whatever it was talking to is not. In scraping this matters because there are usually two candidate gateways, the site's and your own proxy, and they need different fixes.
Which gateway is failing
Work out who generated the error before doing anything else.
The response body is the fastest clue. A site's own gateway typically returns a branded or default nginx page. A proxy provider's gateway returns its own error format, often JSON, sometimes with a provider-specific code. Cloudflare in particular puts a numeric error on the page, and its 5xx variants such as 520 and 522 are more specific than a bare 502.
The second clue is whether it reproduces without the proxy. If the request succeeds direct and 502s through the proxy chain, the chain is the problem.
When the proxy chain is the cause
This is the more common case in scraping, and it looks like:
- A dead exit node. Residential proxy pools rotate through real connections, and some of them go offline mid-request. A retry lands on a different node and succeeds, which is why intermittent 502s that clear on retry usually mean node churn rather than anything about the target.
- Upstream connection limits. Pushing more concurrent connections than the proxy tier allows can produce 502s rather than an explicit rate limit.
- HTTPS through a proxy that mishandles CONNECT. Misconfigured tunnelling shows up as a gateway error rather than a TLS error.
Intermittent, spread across unrelated targets, clearing on retry: proxy chain. Consistent, on one host, at every attempt: that host.
When the site is the cause
A site's own 502 means its application servers are unreachable from its load balancer, usually during a deploy or an outage. Nothing about your request is involved and nothing you change will help. Back off with jitter and retry later.
Where Zenrows fits
Node-level failures are handled inside Zenrows rather than surfacing to you, so the intermittent proxy variety of 502 largely disappears. Requests are billed on success, which means a failed fetch is not something you pay for and then retry. If you are driving proxy endpoints directly, the proxy troubleshooting guide covers gateway failures specifically.
Key takeaways
A 502 says a middleman got an unusable answer from whatever sits behind it. Identify which middleman before reacting: intermittent 502s across unrelated hosts that clear on retry point at your proxy chain, while consistent 502s on a single host point at that site's infrastructure and are not yours to fix.
Go deeper on the blog
In the docs
Last updated: Aug 16, 2026