Jump to solution
Verify

The Fix

pip install urllib3==1.25

Based on closed urllib3/urllib3 issue #355 · 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
@@ -2,7 +2,10 @@ from urllib3.poolmanager import PoolManager from urllib3 import connection_from_url -from urllib3.exceptions import ClosedPoolError +from urllib3.exceptions import ( + ClosedPoolError,
repro.py
>> import urllib3 >> http = urllib3.PoolManager() >> r = http.request('GET', 'http://@') Traceback (most recent call last): File "<stdin>", line 1, in <module> File ".../urllib3/request.py", line 75, in request **urlopen_kw) File ".../urllib3/request.py", line 88, in request_encode_url return self.urlopen(method, url, **urlopen_kw) File ".../urllib3/poolmanager.py", line 145, in urlopen conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme) File ".../urllib3/poolmanager.py", line 119, in connection_from_host pool = self._new_pool(scheme, host, port) File ".../urllib3/poolmanager.py", line 86, in _new_pool return pool_cls(host, port, **kwargs) File ".../urllib3/connectionpool.py", line 226, in __init__ ConnectionPool.__init__(self, host, port) File ".../urllib3/connectionpool.py", line 156, in __init__ host = host.strip('[]') AttributeError: 'NoneType' object has no attribute 'strip'
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 urllib3==1.25\nWhen NOT to use: Do not use this fix if the application relies on None being a valid host.\n\n

Why This Fix Works in Production

  • Trigger: >> import urllib3
  • Mechanism: The connection_from_host method assumes host will never be None, leading to an AttributeError
  • Why the fix works: Raises a LocationParseError if the host is None, addressing the issue of handling malformed URLs. (first fixed release: 1.25).
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

  • The connection_from_host method assumes host will never be None, leading to an AttributeError
  • Surfaces as: >> import urllib3

Proof / Evidence

  • GitHub issue: #355
  • Fix PR: https://github.com/urllib3/urllib3/pull/357
  • First fixed release: 1.25
  • 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.35

Discussion

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

“Sounds reasonable to me, what do you think @shazow?”
@kevinburke · 2014-03-13 · source
“On thinking about it a little more, maybe it's better to leave parse_url alone - it's documented to be usable for relative URLs after all”
@zackw · 2014-03-14 · source
“Hmm. IMO parse_url should parse an empty-host string if possible as host=None. At that point, the Connection-related class should raise the appropriate exception. What do…”
@shazow · 2014-03-14 · source

Failure Signature (Search String)

  • >> import urllib3

Error Message

Stack trace
error.txt
Error Message ------------- >> import urllib3 >> http = urllib3.PoolManager() >> r = http.request('GET', 'http://@') Traceback (most recent call last): File "<stdin>", line 1, in <module> File ".../urllib3/request.py", line 75, in request **urlopen_kw) File ".../urllib3/request.py", line 88, in request_encode_url return self.urlopen(method, url, **urlopen_kw) File ".../urllib3/poolmanager.py", line 145, in urlopen conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme) File ".../urllib3/poolmanager.py", line 119, in connection_from_host pool = self._new_pool(scheme, host, port) File ".../urllib3/poolmanager.py", line 86, in _new_pool return pool_cls(host, port, **kwargs) File ".../urllib3/connectionpool.py", line 226, in __init__ ConnectionPool.__init__(self, host, port) File ".../urllib3/connectionpool.py", line 156, in __init__ host = host.strip('[]') AttributeError: 'NoneType' object has no attribute 'strip'

Minimal Reproduction

repro.py
>> import urllib3 >> http = urllib3.PoolManager() >> r = http.request('GET', 'http://@') Traceback (most recent call last): File "<stdin>", line 1, in <module> File ".../urllib3/request.py", line 75, in request **urlopen_kw) File ".../urllib3/request.py", line 88, in request_encode_url return self.urlopen(method, url, **urlopen_kw) File ".../urllib3/poolmanager.py", line 145, in urlopen conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme) File ".../urllib3/poolmanager.py", line 119, in connection_from_host pool = self._new_pool(scheme, host, port) File ".../urllib3/poolmanager.py", line 86, in _new_pool return pool_cls(host, port, **kwargs) File ".../urllib3/connectionpool.py", line 226, in __init__ ConnectionPool.__init__(self, host, port) File ".../urllib3/connectionpool.py", line 156, in __init__ host = host.strip('[]') AttributeError: 'NoneType' object has no attribute 'strip'

What Broke

Requests to malformed URLs result in AttributeError, causing application crashes.

Why It Broke

The connection_from_host method assumes host will never be None, leading to an AttributeError

Fix Options (Details)

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

pip install urllib3==1.25

When NOT to use: Do not use this fix if the application relies on None being a valid host.

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

Fix reference: https://github.com/urllib3/urllib3/pull/357

First fixed release: 1.25

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

  • Do not use this fix if the application relies on None being a valid host.

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 CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
  • Upgrade behind a canary and run integration tests against the canary before 100% rollout.
  • 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
1.25 Fixed

Related Issues

No related fixes found.

Sources

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