Jump to solution
Verify

The Fix

pip install requests==2.27.0

Based on closed psf/requests issue #2720 · PR/commit linked

Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.

Jump to Verify Open PR/Commit
@@ -499,7 +499,9 @@ def should_bypass_proxies(url): # We need to check whether we match here. We need to see if we match # the end of the netloc, both with and without the port. - no_proxy = no_proxy.replace(' ', '').split(',') + no_proxy = ( + host for host in no_proxy.replace(' ', '').split(',') if host
repro.py
WARNING:root:<class 'requests.exceptions.ConnectTimeout'> HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url: /1.1/statuses/update.json (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f031cdf7908>, 'Connection to api.twitter.com timed out. (connect timeout=5)')) ERROR:__main__:Tweet exception Traceback (most recent call last): File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 134, in _new_conn (self.host, self.port), self.timeout, **extra_kw) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 88, in create_connection raise err File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 78, in create_connection sock.connect(sa) socket.timeout: timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 544, in urlopen body=body, headers=headers) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 341, in _make_request self._validate_conn(conn) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 761, in _validate_conn conn.connect() File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 204, in connect conn = self._new_conn() File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 139, in _new_conn (self.host, self.timeout)) requests.packages.urllib3.exceptions.ConnectTimeoutError: (<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f031cdf7908>, 'Connection to api.twitter.com timed out. (connect timeout=5)') During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/adapters.py", line 370, in send timeout=timeout File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 597, in urlopen _stacktrace=sys.exc_info()[2]) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/util/retry.py", line 271, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url: /1.1/statuses/update.json (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f031cdf7908>, 'Connection to api.twitter.com timed out. (connect timeout=5)')) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/troy/BUDDIES/lib/python3.4/site-packages/TwitterAPI/TwitterAPI.py", line 121, in request proxies=self.proxies) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/sessions.py", line 465, in request resp = self.send(prep, **send_kwargs) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/sessions.py", line 573, in send r = adapter.send(request, **kwargs) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/adapters.py", line 419, in send raise ConnectTimeout(e, request=request) requests.exceptions.ConnectTimeout: HTTP ... (truncated) ...
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\npip install requests==2.27.0\nWhen NOT to use: This fix is not applicable if the no_proxy variable is used correctly without extra commas.\n\n

Why This Fix Works in Production

  • Trigger: WARNING:root:<class 'requests.exceptions.ConnectTimeout'> HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url:…
  • Mechanism: The parsing of the no_proxy environment variable does not tolerate extra commas
  • Why the fix works: Fixes the issue with extra commas in the no_proxy environment variable by ignoring empty fields. (first fixed release: 2.27.0).
Production impact:
  • If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.

Why This Breaks in Prod

  • Shows up under Python 3.4 in real deployments (not just unit tests).
  • The parsing of the no_proxy environment variable does not tolerate extra commas
  • Surfaces as: WARNING:root:<class 'requests.exceptions.ConnectTimeout'> HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url: /1.1/statuses/update.json (Caused…

Proof / Evidence

  • GitHub issue: #2720
  • Fix PR: https://github.com/psf/requests/pull/2721
  • First fixed release: 2.27.0
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-07
  • Confidence: 0.95
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.30

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“Yup, this looks like a legitimate bug: our parsing of the no_proxy environment variable does not tolerate spaces. I think we can fix this up…”
@Lukasa · 2015-08-13 · source
“Hey Guys, Here's quick solution for this PIP bug. simply Take HTTP_PROXY and HTTPS_PROXY env. vars and delete those from your system. Whenever you connect…”
@seema-kote · 2017-10-05 · source
“@seema-kote how to use no_proxy bypass every url”
@QGB · 2018-06-22 · source

Failure Signature (Search String)

  • WARNING:root:<class 'requests.exceptions.ConnectTimeout'> HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url: /1.1/statuses/update.json (Caused

Error Message

Stack trace
error.txt
Error Message ------------- WARNING:root:<class 'requests.exceptions.ConnectTimeout'> HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url: /1.1/statuses/update.json (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f031cdf7908>, 'Connection to api.twitter.com timed out. (connect timeout=5)')) ERROR:__main__:Tweet exception Traceback (most recent call last): File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 134, in _new_conn (self.host, self.port), self.timeout, **extra_kw) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 88, in create_connection raise err File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 78, in create_connection sock.connect(sa) socket.timeout: timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 544, in urlopen body=body, headers=headers) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 341, in _make_request self._validate_conn(conn) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests ... (truncated) ...

Minimal Reproduction

repro.py
WARNING:root:<class 'requests.exceptions.ConnectTimeout'> HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url: /1.1/statuses/update.json (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f031cdf7908>, 'Connection to api.twitter.com timed out. (connect timeout=5)')) ERROR:__main__:Tweet exception Traceback (most recent call last): File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 134, in _new_conn (self.host, self.port), self.timeout, **extra_kw) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 88, in create_connection raise err File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 78, in create_connection sock.connect(sa) socket.timeout: timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 544, in urlopen body=body, headers=headers) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 341, in _make_request self._validate_conn(conn) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 761, in _validate_conn conn.connect() File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 204, in connect conn = self._new_conn() File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 139, in _new_conn (self.host, self.timeout)) requests.packages.urllib3.exceptions.ConnectTimeoutError: (<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f031cdf7908>, 'Connection to api.twitter.com timed out. (connect timeout=5)') During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/adapters.py", line 370, in send timeout=timeout File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 597, in urlopen _stacktrace=sys.exc_info()[2]) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/packages/urllib3/util/retry.py", line 271, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url: /1.1/statuses/update.json (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f031cdf7908>, 'Connection to api.twitter.com timed out. (connect timeout=5)')) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/troy/BUDDIES/lib/python3.4/site-packages/TwitterAPI/TwitterAPI.py", line 121, in request proxies=self.proxies) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/sessions.py", line 465, in request resp = self.send(prep, **send_kwargs) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/sessions.py", line 573, in send r = adapter.send(request, **kwargs) File "/home/troy/BUDDIES/lib/python3.4/site-packages/requests/adapters.py", line 419, in send raise ConnectTimeout(e, request=request) requests.exceptions.ConnectTimeout: HTTP ... (truncated) ...

Environment

  • Python: 3.4

What Broke

Proxy requests fail with ConnectTimeout errors when no_proxy has extra commas.

Why It Broke

The parsing of the no_proxy environment variable does not tolerate extra commas

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install requests==2.27.0

When NOT to use: This fix is not applicable if the no_proxy variable is used correctly without extra commas.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Fix reference: https://github.com/psf/requests/pull/2721

First fixed release: 2.27.0

Last verified: 2026-02-07. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix is not applicable if the no_proxy variable is used correctly without extra commas.

Verify Fix

verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Track RSS + object counts after deployments; alert on monotonic growth and GC pressure.
  • Add a long-running test that repeats the failing call path and asserts stable memory.
  • Make timeouts explicit and test them (unit + integration) to avoid silent behavior changes.
  • Instrument retries (attempt count + reason) and alert on spikes to catch dependency slowdowns.

Version Compatibility Table

VersionStatus
2.27.0 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.