The Fix
pip install urllib3==1.26.9
Based on closed urllib3/urllib3 issue #2534 · 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%.
@@ -55,6 +55,7 @@
"ssl_context",
"key_password",
+ "server_hostname",
)
# Default value for `blocksize` - a new parameter introduced to
>> import platform
>> import urllib3
>>
>> print("OS", platform.platform())
OS Linux-5.11.22-100.fc32.x86_64-x86_64-with-glibc2.2.5
>> print("Python", platform.python_version())
Python 3.8.10
>> print("urllib3", urllib3.__version__)
urllib3 1.26.8
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\npip install urllib3==1.26.9\nWhen NOT to use: Do not use this fix if server_hostname is not required for your application.\n\n
Why This Fix Works in Production
- Trigger: >> import urllib3
- Mechanism: TypeError occurs due to server_hostname not being accepted by HTTPConnection
- Why the fix works: Adds support for the server_hostname parameter in the PoolManager, resolving a TypeError when making HTTP requests. (first fixed release: 1.26.9).
- 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.8.10 in real deployments (not just unit tests).
- TypeError occurs due to server_hostname not being accepted by HTTPConnection
- Surfaces as: >> import urllib3
Proof / Evidence
- GitHub issue: #2534
- Fix PR: https://github.com/urllib3/urllib3/pull/2537
- First fixed release: 1.26.9
- 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.22
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“As far as I can tell a new version of urllib3 including this fix has not yet been released. 1.26.8 is the latest on pypi.…”
“FYI: This was initially reported in https://github.com/cdent/gabbi/issues/309 .”
“Just adding some more results..”
Failure Signature (Search String)
- >> import urllib3
Error Message
Stack trace
Error Message
-------------
>> import urllib3
>> manager = urllib3.PoolManager(server_hostname='foo')
>> manager.urlopen('GET', 'http://127.0.0.1')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/poolmanager.py", line 375, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/connectionpool.py", line 692, in urlopen
conn = self._get_conn(timeout=pool_timeout)
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/connectionpool.py", line 281, in _get_conn
return conn or self._new_conn()
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/connectionpool.py", line 235, in _new_conn
conn = self.ConnectionCls(
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/connection.py", line 130, in __init__
_HTTPConnection.__init__(self, *args, **kw)
TypeError: __init__() got an unexpected keyword argument 'server_hostname'
Stack trace
Error Message
-------------
>> import urllib3
>> manager = urllib3.PoolManager(server_hostname='foo')
>> manager.urlopen('GET', 'https://127.0.0.1')
Traceback (most recent call last):
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/util/connection.py", line 95, in create_connection
raise err
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/util/connection.py", line 85, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1040, in _validate_conn
conn.connect()
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/connection.py", line 358, in connect
conn = self._new_conn()
File "/home/tkajinam/virtualenv/foo/lib/python3.8/si
... (truncated) ...
Stack trace
Error Message
-------------
>> manager = urllib3.PoolManager()
>> manager.urlopen('GET', 'http://127.0.0.1')
Traceback (most recent call last):
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/util/connection.py", line 95, in create_connection
raise err
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/util/connection.py", line 85, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/connectionpool.py", line 398, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/home/tkajinam/virtualenv/foo/lib/python3.8/site-packages/urllib3/connection.py", line 239, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/lib64/python3.8/http/client.py", line 1252, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib64/python3
... (truncated) ...
Minimal Reproduction
>> import platform
>> import urllib3
>>
>> print("OS", platform.platform())
OS Linux-5.11.22-100.fc32.x86_64-x86_64-with-glibc2.2.5
>> print("Python", platform.python_version())
Python 3.8.10
>> print("urllib3", urllib3.__version__)
urllib3 1.26.8
Environment
- Python: 3.8.10
- urllib3: 1.26.8
What Broke
TypeError prevents HTTP requests from being sent, causing application failures.
Why It Broke
TypeError occurs due to server_hostname not being accepted by HTTPConnection
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install urllib3==1.26.9
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/2537
First fixed release: 1.26.9
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if server_hostname is not required for your application.
Verify Fix
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
| Version | Status |
|---|---|
| 1.26.9 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.