Jump to solution
Verify

The Fix

pip install requests==2.32.0

Based on closed psf/requests issue #6643 · 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
@@ -390,6 +390,9 @@ def request_url(self, request, proxies): url = request.path_url + if url.startswith("//"): # Don't confuse urllib3 + url = f"/{url.lstrip('/')}" +
repro.py
Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/urllib3/util/url.py", line 425, in parse_url host, port = _HOST_PORT_RE.match(host_port).groups() # type: ignore[union-attr] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'groups' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 73, in get return request("get", url, params=params, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 59, in request return session.request(method=method, url=url, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, **send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 486, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 711, in urlopen parsed_url = parse_url(url) ^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/urllib3/util/url.py", line 451, in parse_url raise LocationParseError(source_url) from e urllib3.exceptions.LocationParseError: Failed to parse: //v:h
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.32.0\nWhen NOT to use: This fix is not applicable for URLs where leading slashes are intended for valid paths.\n\n

Why This Fix Works in Production

  • Trigger: host, port = _HOST_PORT_RE.match(host_port).groups() # type: ignore[union-attr]
  • Mechanism: Leading slashes in the URL path cause urllib3 to misinterpret the URL structure
  • Why the fix works: Trim excess leading path separators to prevent URL parsing issues in urllib3. (first fixed release: 2.32.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.11 in real deployments (not just unit tests).
  • Leading slashes in the URL path cause urllib3 to misinterpret the URL structure
  • Surfaces as: Traceback (most recent call last):

Proof / Evidence

  • GitHub issue: #6643
  • Fix PR: https://github.com/psf/requests/pull/6644
  • First fixed release: 2.32.0
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-09
  • Confidence: 0.85
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.31

Discussion

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

“I can reproduce this with cc @sethmlarson @pquentin”
@sigmavirus24 · 2024-02-22 · source
“Also, yes, I verified that RFC3986 allows : as a non-percent-encoded character in the path: https://datatracker.ietf.org/doc/html/rfc3986.html#section-3.3”
@sigmavirus24 · 2024-02-22 · source
“And I think the problem is the // in the path which is tripping up the parsing as // is the delimiter for what should…”
@sigmavirus24 · 2024-02-22 · source
“Also reported this up to urllib3 https://github.com/urllib3/urllib3/issues/3352”
@sigmavirus24 · 2024-02-22 · source

Failure Signature (Search String)

  • host, port = _HOST_PORT_RE.match(host_port).groups() # type: ignore[union-attr]

Error Message

Stack trace
error.txt
Error Message ------------- Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/urllib3/util/url.py", line 425, in parse_url host, port = _HOST_PORT_RE.match(host_port).groups() # type: ignore[union-attr] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'groups' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 73, in get return request("get", url, params=params, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 59, in request return session.request(method=method, url=url, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, **send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 486, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-pac ... (truncated) ...

Minimal Reproduction

repro.py
Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/urllib3/util/url.py", line 425, in parse_url host, port = _HOST_PORT_RE.match(host_port).groups() # type: ignore[union-attr] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'groups' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 73, in get return request("get", url, params=params, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/api.py", line 59, in request return session.request(method=method, url=url, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, **send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 486, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 711, in urlopen parsed_url = parse_url(url) ^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/urllib3/util/url.py", line 451, in parse_url raise LocationParseError(source_url) from e urllib3.exceptions.LocationParseError: Failed to parse: //v:h

Environment

  • Python: 3.11

What Broke

Requests to URLs with leading slashes result in AttributeError due to parsing failure.

Why It Broke

Leading slashes in the URL path cause urllib3 to misinterpret the URL structure

Fix Options (Details)

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

pip install requests==2.32.0

When NOT to use: This fix is not applicable for URLs where leading slashes are intended for valid paths.

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/6644

First fixed release: 2.32.0

Last verified: 2026-02-09. 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 for URLs where leading slashes are intended for valid paths.

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

  • Add a TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
  • Alert on handshake failures by error string and endpoint to catch cert/CA changes quickly.
  • 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.

Version Compatibility Table

VersionStatus
2.32.0 Fixed

Related Issues

No related fixes found.

Sources

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