4

Got ERR_TUNNEL_CONNECTION_FAILED in Chrome and no idea why? Try the same proxy from Python, because it'll tell you what the browser won't. Chromium drops every CONNECT reply except 200 and 407, so you can't tell a policy block from a dead exit in there.

Python leaves the status in the exception text. You'll see OSError: Tunnel connection failed: 502 Bad Gateway from http.client, and requests wraps that in a ProxyError with the same words inside.

I'd read that string before retrying anything, since a blanket except ProxyError plus a retry loop just burns time on errors that can't heal. A 403 is usually policy, sometimes just a port they don't allow. 407 means check your login. If you get 405 or 501 you aren't talking to a forward proxy at all. Only 502, 503 and 504 are worth backing off on, those happened behind the proxy.

Disclosure: we run a proxy service, none of this depends on whose.

no comments (yet)
sorted by: hot top new old
there doesn't seem to be anything here
this post was submitted on 08 Nov 2026
4 points (83.3% liked)

Python

8122 readers
1 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 3 years ago
MODERATORS