Retry on a fresh session
Changing the -session-<id> value in the username forces a different exit IP on the next request. Two or three attempts with new sessions and short backoff clears almost every transient 502 without slowing the crawl.
HTTP 502 means an intermediary server — a CDN edge, load balancer, reverse proxy, or the proxy you configured — contacted the server behind it and got an invalid response or none at all. The same three digits can point at opposite problems, so the fix starts with identifying which hop actually generated the error.
A 502 means a server acting as an intermediary — a CDN edge, load balancer, or reverse proxy — forwarded your request to the server behind it and got back an invalid response or none at all: a refused connection, a reset, malformed data, or a crash mid-response. The intermediary is fine; the machine behind it is not, at least for that request.
When your requests travel through a forward proxy, two different intermediaries can produce the same code. The target's own edge returns a 502 when its origin is down or overloaded — everyone gets that one, proxy or not. Your proxy returns a 502 when its outbound connection to the target fails — only your configured path gets that one. The three digits are identical; the fixes are opposites.
Attribution is usually cheap: read the response body and headers. CDN and hosting layers ship recognizable branded error pages and distinctive Server headers, while proxy-generated 502s tend to be short and generic. When in doubt, the direct-versus-proxied comparison in the steps below settles it.
502s are the most retryable of the 5xx family, but blind retries waste time when the origin is genuinely down. These steps identify the failing hop first, then apply the fix that matches.
Server header to identify which layer generated the page — hosting and CDN error pages are branded and distinctive, proxy-generated ones are short and generic.-session- ID) so the request uses a different exit IP. A single exit's route to a target can fail transiently while every other route is healthy.With rotating residential proxies, an isolated 502 usually means one thing: that particular exit's connection to the target failed at that moment. Residential exits are real consumer connections, so a small tail of transient route failures is expected behavior, not a fault — it is why honest success rates are quoted at 99.7% rather than in absolutes. The engineering response is a cheap retry on a different exit, which converts nearly all of that tail into successes.
Patterns tell you more than single errors do. 502s concentrated on one target across many exits point at that origin; 502s that appear only when you raise concurrency point at overload; 502s across all targets point at your own configuration. Match the pattern before changing anything.
Changing the -session-<id> value in the username forces a different exit IP on the next request. Two or three attempts with new sessions and short backoff clears almost every transient 502 without slowing the crawl.
Log which URL, session ID, and timestamp produced each 502. One target failing through every exit is an origin problem to wait out; failures that scale with your request rate are overload you should back off from.
For long-lived connections and latency-sensitive endpoints, Platinum's Tier-1 ISP-quality routes (with country, state, city, and ASN targeting) or a dedicated Static ISP IP hold steadier paths than rotating pools — fewer route changes, fewer mid-transfer failures.
The canonical pattern: bounded retries, exponential backoff, and a new sticky-session ID per attempt so each retry leaves from a different exit IP. Anything still failing after three attempts goes back on the queue instead of blocking the crawl.
import time
import requests
def fetch(url, attempts=3):
resp = None
for i in range(attempts):
# New -session- id per attempt = different exit IP
user = f"USERNAME-country-us-session-retry{i}"
proxy = f"http://{user}:[email protected]:10000"
resp = requests.get(url, proxies={"http": proxy, "https": proxy},
timeout=30)
if resp.status_code != 502:
return resp
time.sleep(2 ** i)
return resp
resp = fetch("https://example.com/category/widgets")
print(resp.status_code)Rotating residential, ISP-quality, and mobile exits with per-session control across 200+ countries.
90M+ ethically-sourced IPs across 200+ countries and 30,000+ cities. Residential, mobile, ISP and IPv6 proxies for scraping and AI agents.