Prompt
How do I fix proxy errors in my scraping pipeline?
Latest observation
Proxy errors in a scraping pipeline usually come from one of a few buckets: the proxy is down/blocked, credentials or formatting are wrong, the target site is rejecting the proxy IP, or your client is misconfigured.
1) Identify the exact error
Different errors point to different fixes:
- 407 Proxy Authentication Required
Bad username/password, wrong auth format, or proxy doesn’t allow that account. - 403 / 429 from target site
Proxy works, but the destination is blocking or rate-limiting you. - 502 / 503 / 504
Proxy provider or upstream target is unstable; often transient. - Connection timed out / refused
Bad proxy host/port, dead proxy, firewall, DNS issue, or network restrictions. - SSL / TLS handshake errors
HTTPS proxying issue, certificate interception, or client/proxy protocol mismatch.
2) Verify proxy formatting
Make sure your proxy URL is correct.
Examples:
- HTTP proxy:
http://user:pass@host:port
- HTTPS requests through an HTTP proxy:
- still usually
http://user:pass@host:port
- still usually
- SOCKS5:
socks5://user:pass@host:port
Common mistakes:
- Missing
http://orsocks5:// - Using the wrong port
- Special characters in password not URL-encoded (
@,:,#, etc.) - Passing the proxy in the wrong field for your library
3) Test the proxy outside your scraper
Before debugging the whole pipeline, test a single request:
curl -x http://user:pass@host:port https://httpbin.org/ip -v
If that fails, the issue is proxy-side, not your scraper.
For Python:
import requests
proxies = {
"http": "http://user:pass@host:port",
"https": "http://user:pass@host:port",
}
r = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=30)
print(r.status_code, r.text)
4) Check whether the proxy supports your use case
Some proxies:
- Don’t support HTTPS tunneling
- Don’t support SOCKS
- Require IP allowlisting instead of username/password
- Only work from certain regions
- Have concurrency limits
Ask your provider:
- Is the proxy HTTP, HTTPS, SOCKS4, or SOCKS5?
- Do I need IP whitelist or auth?
- Are there rate limits or banned targets?
5) Add retries with backoff
Many proxy errors are transient. Retry on network errors and 5xx responses.
Use:
- limited retries
- exponential backoff
- jitter
- different proxy on retry, if available
Avoid retrying endlessly on persistent auth/format errors.
6) Rotate proxies and sessions properly
If the target blocks a proxy IP:
- rotate to a different exit IP
- keep cookies/session consistent when needed
- avoid sending too many requests from one IP too quickly
If you use sticky sessions, make sure the session is actually sticky with your provider.
7) Reduce blocking signals
Proxy errors can be a symptom of anti-bot defenses.
Try:
- realistic headers (
User-Agent,Accept-Language, etc.) - cookies / session persistence
- slower request rates
- randomized delays
- consistent fingerprints across requests
- using browser automation when the site requires JS
8) Validate DNS and TLS behavior
If you see weird target resolution or certificate issues:
- try resolving DNS via the proxy if supported
- ensure your client trusts the certificate chain
- check whether your proxy provider intercepts TLS
- try another endpoint to isolate whether it’s site-specific
9) Log and classify failures
Log:
- proxy host/port
- proxy type
- target URL
- status code
- exception message
- latency
- whether the error happened on connect, TLS, or response
This helps distinguish:
- bad proxy
- bad credentials
- target blocking
- rate limiting
- provider outage
10) If using a library, check its proxy config
Examples of common pitfalls:
requests
Use:
proxies = {
"http": "http://user:pass@host:port",
"https": "http://user:pass@host:port",
}
aiohttp
Use proxy= per request or a connector setup.
selenium
Set proxy at browser level, not just in HTTP client settings.
scrapy
Use meta["proxy"] = "http://user:pass@host:port" or middleware.
Quick checklist
- Proxy host/port correct
- Protocol matches proxy type
- Credentials correct and URL-encoded
- Proxy works in
curl - HTTPS/SOCKS supported
- Timeouts/retries configured
- Rotation/rate limits reasonable
- Target site not blocking proxy IP
- Logs distinguish connect vs auth vs target errors
If you want, I can help you debug a specific proxy error message or review your code snippet.