Proxy Connection Errors: Troubleshooting Guide

Proxy Connection Errors: Troubleshooting Guide

Proxy connection errors prevent your requests from reaching the target server through a proxy. Whether you are using proxies for web scraping, privacy, or geo-unblocking, connection failures are the most common issue. This guide covers every proxy error you might encounter and how to fix it.

Common Proxy Connection Errors

ErrorToolMeaning
curl: (5) Could not resolve proxycURLProxy hostname DNS failed
curl: (7) Failed to connect to proxycURLCannot reach proxy server
curl: (56) Proxy CONNECT abortedcURLProxy refused the CONNECT request
curl: (97) Proxy handshake errorcURLHTTPS proxy handshake failed
407 Proxy Authentication RequiredAnyProxy needs credentials
ProxyErrorPython requestsGeneral proxy connection failure
ConnectionRefusedErrorPythonProxy port is closed
SOCKSHTTPSConnectionPoolPythonSOCKS proxy configuration error
ERR_PROXY_CONNECTION_FAILEDChromeBrowser proxy connection failed
Tunnel connection failed: 403AnyProxy blocked the CONNECT tunnel

Diagnosing Proxy Issues

Step 1: Verify Proxy Is Reachable

# Test TCP connectivity to proxy

nc -zv proxy.example.com 8080

telnet proxy.example.com 8080

Check with cURL verbose mode

curl -v -x http://proxy.example.com:8080 https://httpbin.org/ip

Check proxy response time

curl -x http://user:pass@proxy.example.com:8080 \

-w "Connect: %{time_connect}s\nTotal: %{time_total}s\n" \

-o /dev/null -s https://httpbin.org/ip

Step 2: Test Without Proxy

# Confirm the target works without proxy

curl https://httpbin.org/ip

Compare with proxy

curl -x http://user:pass@proxy.example.com:8080 https://httpbin.org/ip

Step 3: Check Proxy Authentication

# Test with credentials

curl -x http://proxy.example.com:8080 --proxy-user username:password https://httpbin.org/ip

URL-encoded credentials (if password has special characters)

curl -x http://username:p%40ssw0rd@proxy.example.com:8080 https://httpbin.org/ip

Fix 1: Cannot Connect to Proxy

Error: curl: (7) Failed to connect to proxy or ConnectionRefusedError

# Check if proxy host is reachable

ping proxy.example.com

Check if proxy port is open

nc -zv proxy.example.com 8080

Try a different port (proxies often run on multiple ports)

curl -x http://proxy.example.com:3128 https://httpbin.org/ip

curl -x http://proxy.example.com:8888 https://httpbin.org/ip

Common causes:

  • Proxy server is down
  • Wrong hostname or port
  • Firewall blocking outbound connections to the proxy
  • Proxy IP has changed

Fix 2: Proxy Authentication Failed

Error: 407 Proxy Authentication Required

# Verify credentials work

curl -x http://proxy.example.com:8080 -U "username:password" https://httpbin.org/ip

URL-encode special characters in password

@ = %40, # = %23, ! = %21, : = %3A

curl -x "http://username:p%40ss%23word@proxy.example.com:8080" https://httpbin.org/ip

from urllib.parse import quote

username = "user"

password = "p@ss#word!"

encoded_pass = quote(password, safe="")

proxies = {

"http": f"http://{username}:{encoded_pass}@proxy.example.com:8080",

"https": f"http://{username}:{encoded_pass}@proxy.example.com:8080",

}

response = requests.get("https://httpbin.org/ip", proxies=proxies)

Fix 3: HTTPS/SSL Issues Through Proxy

Error: curl: (35) SSL connect error or curl: (97) Proxy handshake error

# Test SSL through proxy

curl -v -x http://proxy.example.com:8080 https://httpbin.org/ip

Skip SSL verification (debugging only)

curl -k -x http://proxy.example.com:8080 https://httpbin.org/ip

Force TLS version

curl --tlsv1.2 -x http://proxy.example.com:8080 https://httpbin.org/ip

Fix 4: SOCKS Proxy Errors

# SOCKS5 with remote DNS resolution (recommended)

curl --socks5-hostname proxy.example.com:1080 https://httpbin.org/ip

SOCKS5 with local DNS

curl --socks5 proxy.example.com:1080 https://httpbin.org/ip

SOCKS5 with authentication

curl --socks5-hostname user:pass@proxy.example.com:1080 https://httpbin.org/ip

# Install socks support

pip install requests[socks]

import requests

SOCKS5 with remote DNS (note: socks5h, not socks5)

proxies = {

"http": "socks5h://user:pass@proxy.example.com:1080",

"https": "socks5h://user:pass@proxy.example.com:1080",

}

response = requests.get("https://httpbin.org/ip", proxies=proxies)

Fix 5: Proxy Timeout Issues

# Increase connection timeout

curl -x http://proxy.example.com:8080 --connect-timeout 30 --max-time 60 https://example.com

Retry on timeout

curl -x http://proxy.example.com:8080 --retry 3 --retry-delay 5 https://example.com

import requests

proxies = {"https": "http://user:pass@proxy.example.com:8080"}

response = requests.get(

"https://example.com",

proxies=proxies,

timeout=(10, 30), # (connect_timeout, read_timeout)

)

Fix 6: Proxy Rotating / Pool Issues

When using rotating proxies, some IPs in the pool may be dead or blocked.

import requests

import time

def request_with_proxy_retry(url, proxy_url, max_retries=3):

proxies = {"http": proxy_url, "https": proxy_url}

for attempt in range(max_retries):

try:

response = requests.get(url, proxies=proxies, timeout=15)

if response.status_code in [407, 502, 503]:

print(f"Proxy error {response.status_code}, retrying...")

time.sleep(2)

continue

return response

except (requests.exceptions.ProxyError,

requests.exceptions.ConnectionError,

requests.exceptions.Timeout) as e:

print(f"Proxy connection failed: {e}")

time.sleep(2)

raise Exception("All proxy retries failed")

Proxy Configuration Quick Reference

# HTTP proxy

curl -x http://proxy:8080 https://example.com

HTTPS proxy

curl -x https://proxy:8443 https://example.com

SOCKS4

curl --socks4 proxy:1080 https://example.com

SOCKS5

curl --socks5-hostname proxy:1080 https://example.com

Environment variables

export http_proxy="http://user:pass@proxy:8080"

export https_proxy="http://user:pass@proxy:8080"

export no_proxy="localhost,127.0.0.1,.internal.com"

curl https://example.com

import requests

import os

Method 1: Pass directly

proxies = {"http": "http://user:pass@proxy:8080", "https": "http://user:pass@proxy:8080"}

requests.get("https://example.com", proxies=proxies)

Method 2: Environment variables (requests reads these automatically)

os.environ["HTTP_PROXY"] = "http://user:pass@proxy:8080"

os.environ["HTTPS_PROXY"] = "http://user:pass@proxy:8080"

requests.get("https://example.com")

Troubleshooting Checklist

StepCheckCommand
1Proxy is reachablenc -zv proxy 8080
2Credentials are correctCheck provider dashboard
3Password is URL-encodedEncode @#!: characters
4Proxy protocol is correctHTTP vs SOCKS5 vs HTTPS
5Port is correctCommon: 8080, 3128, 1080
6IP is whitelistedCheck provider settings
7Proxy bandwidth is availableCheck usage dashboard
8Target site is accessibleTest without proxy first



FAQ

Why does my proxy work for HTTP but not HTTPS?

HTTP proxies handle HTTPS through a CONNECT tunnel. If the proxy does not support CONNECT or blocks it for certain domains, HTTPS requests will fail while HTTP works fine.

How do I test if my proxy is working?

Use curl -x http://proxy:8080 https://httpbin.org/ip — it should return the proxy’s IP address, not your real IP.

Can my ISP block proxy connections?

Yes. Some ISPs block common proxy ports. Try using proxies on port 443 (HTTPS port) which is rarely blocked, or use a SOCKS proxy over a non-standard port.

Why is my proxy connection slow?

Slow proxy connections are usually caused by geographic distance between you and the proxy, proxy server overload, or bandwidth limits on your proxy plan. Try a proxy server closer to your location or upgrade your plan.

Scroll to Top