We use Google Analytics and PostHog to see which pages bring in customers and where visitors get stuck. Until you agree both run without cookies — they count the pages you open and what you click, but cannot recognise you across visits. Agreeing lets them use cookies, so we can tell repeat visitors apart, lets PostHog record a replay of your visit, with anything you type hidden, and loads OpenAI’s measurement pixel, which shows us whether a visit came from one of our ads in ChatGPT. Nothing is sent to OpenAI until you agree. Either way we never build advertising profiles or target ads. Privacy Policy

15% off your first purchase with code WELCOME15, up to 25 GB.

See pricing

Guide · Scraping practice

How to fix requests.exceptions.ProxyError: Max retries exceeded

requests.exceptions.ProxyError: ... Max retries exceeded with url is a wrapper. The useful part is the text after Caused by ProxyError(...): Tunnel connection failed: 407 means wrong or missing credentials, Connection refused means nothing is listening on that host and port, Tunnel connection failed: 501 or 502 means the port is not a proxy or the proxy could not reach the site, and an SSLError means the proxy URL starts with https://. "Max retries exceeded" does not mean anything was retried: requests makes one attempt by default. Read the cause, fix that one thing, and check the proxy works with the proxy tester before changing code.

Reviewed 2 Nov 2026

The short answer

  • By default requests does not retry failed connections. We counted exactly one CONNECT per call, despite "Max retries exceeded" in the message.
  • urllib3 2.x prints Unable to connect to proxy; urllib3 1.26 printed Cannot connect to proxy.. Same error, different wording.
  • A proxy that closes the connection gives ConnectionError: ('Connection aborted.', RemoteDisconnected(...)) on urllib3 2.x, not ProxyError.
  • Missing dependencies for SOCKS support is InvalidSchema: install requests[socks].
  • A mounted Retry does retry a 407 (four CONNECTs with total=3), so filter 407 out of your retry logic.

Read the last line: the cause inside the wrapper

Reproduced on 2026-11-02 with Python 3.13.12, requests 2.34.2 and urllib3 2.8.0 against local test proxies, each call requests.get("https://example.com/", proxies={"http": proxy, "https": proxy}). The left column is what follows Caused by in the message.

Cause in the messageWhat it meansFix
ProxyError('Unable to connect to proxy', OSError('Tunnel connection failed: 407 Proxy Authentication Required'))The proxy rejected or did not get the credentialsCheck username and password, URL-encode special characters; see CONNECT tunnel failed, 407
ProxyError('Unable to connect to proxy', NewConnectionError("...Failed to establish a new connection: [Errno 61] Connection refused"))Nothing listening on that host and port (errno 61 on macOS)Check host and port; ARC's gateway is proxy.arcproxies.io:8000
ProxyError('Unable to connect to proxy', OSError("Tunnel connection failed: 501 Unsupported method ('CONNECT')"))The port belongs to a web server, not a proxyUse the proxy's port
ProxyError('Unable to connect to proxy', OSError('Tunnel connection failed: 502 Bad Gateway'))Proxy is fine but could not reach the targetCheck the target hostname; retry later with backoff
ProxyError('Unable to connect to proxy. Your proxy appears to only use HTTP and not HTTPS...', SSLError(...))The proxy URL starts with https:// but the proxy speaks HTTPUse http://; see SSL: WRONG_VERSION_NUMBER
ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))The proxy accepted the connection, then closed it without answeringCheck the port and protocol; retry once, then stop
ConnectionError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))http:// URL pointed at a SOCKS portUse socks5h:// (with requests[socks]) or the HTTP port
InvalidSchema: Missing dependencies for SOCKS support.A socks5:// or socks5h:// URL without PySockspip install "requests[socks]"
InvalidProxyURL: Please check proxy URL. It is malformed and could be missing the host.No scheme in the proxy URLWrite http://user:pass@host:port

"Cannot connect to proxy" vs "Unable to connect to proxy"

The wording comes from urllib3, not requests. We ran the same tests with requests 2.31.0 and urllib3 1.26.20 (Python 3.12.6): every cause above came out as ProxyError('Cannot connect to proxy.', ...), including RemoteDisconnected and ConnectionResetError, which urllib3 2.x reports as a plain ConnectionError instead. If your traceback says "Cannot connect to proxy.", you are on urllib3 1.x and the inner cause still tells you what failed.

With a plain-HTTP target (http://...) there is no tunnel, and a wrong password does not raise at all: requests 2.34.2 returned a response with status_code == 407. Check for that status as well as the exception.

Why it says "Max retries exceeded" when nothing was retried

The message comes from urllib3's MaxRetryError, which requests wraps. requests documents that HTTPAdapter(max_retries=...) defaults to no retries for failed connections, and our test proxy logged one CONNECT per call.

If you mount an adapter with urllib3's Retry, failed tunnels are retried, including a 407 that can never succeed: with Retry(total=3) our proxy logged four CONNECT requests with the wrong password. The Python requests integration has a retry loop that stops on 407.

Checks that solve most cases

  • Test the same proxy string in the proxy tester. If it fails there, fix the credentials or the endpoint before touching code.
  • Print the environment: requests also reads HTTP_PROXY, HTTPS_PROXY and ALL_PROXY, so a stale variable can override what you think you configured. env | grep -i _proxy shows them.
  • Map both keys to the same http:// URL. The key is the scheme of the site, the value is how to reach the proxy.
  • URL-encode special characters in the password (@ as %40, : as %3A). requests 2.34.2 happened to parse p@ss:w0rd unencoded in our test, but curl 8.7.1 refused the same URL, so encode it everywhere.
  • Compare the exit IP with what is my IP when a request succeeds but seems to bypass the proxy.

Code

Worked example

Print the real cause behind ProxyError (ran on urllib3 2.8.0 and 1.26.20)
import requestsfrom requests.exceptions import ProxyError, SSLError, ConnectionError as ConnErrorPROXY = "http://USERNAME_pool-arcfast_country-de:PASSWORD@proxy.arcproxies.io:8000"def root_cause(err: BaseException) -> BaseException:    """Walk to the innermost exception behind requests' wrapper."""    seen = err    while True:        nxt = getattr(seen, "reason", None)        if not isinstance(nxt, BaseException):            nxt = seen.__cause__ or seen.__context__        if nxt is None and seen.args and isinstance(seen.args[-1], BaseException):            nxt = seen.args[-1]        if nxt is None or nxt is seen:            return seen        seen = nxttry:    r = requests.get("https://example.com/", proxies={"http": PROXY, "https": PROXY}, timeout=30)    print(r.status_code)except (ProxyError, SSLError, ConnError) as err:    cause = root_cause(err)    print(f"{type(err).__name__} -> {type(cause).__name__}: {cause}")    # ProxyError -> OSError: Tunnel connection failed: 407 Proxy Authentication Required    # ProxyError -> ConnectionRefusedError: [Errno 61] Connection refused    # ConnectionError -> RemoteDisconnected: Remote end closed connection without response
Full messages as reproduced (requests 2.34.2, urllib3 2.8.0)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='example.com', port=443): Max retries exceeded with url: / (Caused by ProxyError('Unable to connect to proxy', OSError('Tunnel connection failed: 407 Proxy Authentication Required')))requests.exceptions.ProxyError: HTTPSConnectionPool(host='example.com', port=443): Max retries exceeded with url: / (Caused by ProxyError('Unable to connect to proxy', NewConnectionError("HTTPSConnection(host='127.0.0.1', port=18099): Failed to establish a new connection: [Errno 61] Connection refused")))requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))# requests 2.31.0 + urllib3 1.26.20, same proxy closing the connection:requests.exceptions.ProxyError: HTTPSConnectionPool(host='example.com', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', RemoteDisconnected('Remote end closed connection without response')))

FAQ

Questions

Something not covered? Write to contact@arcproxies.io.

What does requests.exceptions.ProxyError Max retries exceeded mean?

requests could not get a working connection through the proxy. The cause is at the end of the message after Caused by: a 407 means wrong credentials, Connection refused means nothing is listening on that host and port, and an SSLError means the proxy URL wrongly starts with https://.

Did requests really retry my request?

Not by default. requests documents that it does not retry failed connections unless you configure max_retries, and our test proxy saw one attempt per call. The words come from urllib3's MaxRetryError.

How do I fix ProxyError Tunnel connection failed: 407?

The proxy rejected the credentials while opening the HTTPS tunnel. Copy the username and password again, URL-encode special characters in the password, and test the same string in a proxy tester. Retrying will not help.

What does Cannot connect to proxy RemoteDisconnected mean?

The proxy accepted the TCP connection and then closed it without answering. On urllib3 1.26 that is reported as ProxyError Cannot connect to proxy; on urllib3 2.x as ConnectionError Connection aborted. Check that the port is the proxy's HTTP port and that the scheme matches.

Why does requests say Missing dependencies for SOCKS support?

The proxy URL uses socks5:// or socks5h:// and PySocks is not installed. Run pip install "requests[socks]". Use socks5h:// so the proxy resolves hostnames.

Should I catch ProxyError and retry?

Only for causes that can change: a 502 or 503 from the proxy, a reset connection or a timeout. A 407, a refused connection or an SSL error from an https:// proxy URL are configuration mistakes and fail the same way every time.

Next

Where to go from here