The Fix
pip install urllib3==1.26.5
Based on closed urllib3/urllib3 issue #517 · 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%.
@@ -30,7 +30,7 @@ class BaseSSLError(BaseException):
)
from .packages.ssl_match_hostname import CertificateError, match_hostname
-from .util import SKIP_HEADER, SKIPPABLE_HEADERS, connection
+from .util import SKIP_HEADER, SKIPPABLE_HEADERS, connection, ssl_
from .util.ssl_ import (
def __init__(self, poolmanager_server_hostname, *args, **kwargs):
self.poolmanager_server_hostname = poolmanager_server_hostname
requests.adapters.HTTPAdapter.__init__(self, *args, **kwargs)
def init_poolmanager(self, *args, **kwargs):
self.poolmanager = requests.adapters.PoolManager(
*args,
server_hostname=self.poolmanager_server_hostname,
**kwargs)
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.5\nWhen NOT to use: This fix should not be used if compatibility with older Python versions is required.\n\n
Why This Fix Works in Production
- Trigger: ... (truncated) ...
- Mechanism: urllib3 did not utilize SSLContext's check_hostname feature for hostname verification
- Why the fix works: Modifies urllib3 to lean on SSLContext for hostname verification when possible, addressing issue #517. (first fixed release: 1.26.5).
- 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).
- urllib3 did not utilize SSLContext's check_hostname feature for hostname verification
- Surfaces as: Traceback (most recent call last):\n File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/basecommand.py", line 232, in main\n status = self.run(options, args)\n…
Proof / Evidence
- GitHub issue: #517
- Fix PR: https://github.com/urllib3/urllib3/pull/2178
- First fixed release: 1.26.5
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.95
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.32
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Currently, it appears that because urllib3 **doesn't** use this, an exception is raised. I haven't had a chance to isolate this yet, but a pip…”
“Followup: This is pip 6.0.7 (obvious from the traceback), which uses requests 2.5.1 (see pypa/pip@ec51b69cd73125e8bb37029d936c57f29b1a00fa) which in turn uses a urllib3 checkout with SHA @a27758625e4169330fcf965652b1093faf5aaaa2…”
“1”
“It's a new ticket, and it's what we should have opened when I closed kennethreitz/requests#2435.”
Failure Signature (Search String)
- ... (truncated) ...
Error Message
Stack trace
Error Message
-------------
Traceback (most recent call last):\n File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/basecommand.py", line 232, in main\n status = self.run(options, args)\n File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/commands/install.py", line 339, in run\n requirement_set.prepare_files(finder)\n File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/req/req_set.py", line 333, in prepare_files\n upgrade=self.upgrade,\n File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/index.py", line 305, in find_requirement\n page = self._get_page(main_index_url, req)\n File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/index.py", line 783, in _get_page\n return HTMLPage.get_page(link, req, session=self.session)\n File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/index.py", line 872, in get_page\n "Cache-Control": "max-age=600",\n File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/_vendor/requests/sessions.py", line 473, in get\n return self.request('GET', url, **kwargs)\n File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/download.py", line 365, in request\n return super(PipSession, self).request(method, url, *args, **kwargs)\n File "/usr/local/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg/pip/_vendor/requests/sessions.py",
... (truncated) ...
Minimal Reproduction
def __init__(self, poolmanager_server_hostname, *args, **kwargs):
self.poolmanager_server_hostname = poolmanager_server_hostname
requests.adapters.HTTPAdapter.__init__(self, *args, **kwargs)
def init_poolmanager(self, *args, **kwargs):
self.poolmanager = requests.adapters.PoolManager(
*args,
server_hostname=self.poolmanager_server_hostname,
**kwargs)
Environment
- Python: 3.4
What Broke
Users experienced exceptions during HTTPS requests due to hostname verification failures.
Why It Broke
urllib3 did not utilize SSLContext's check_hostname feature for hostname verification
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install urllib3==1.26.5
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/2178
First fixed release: 1.26.5
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if compatibility with older Python versions is required.
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.
- 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.
Version Compatibility Table
| Version | Status |
|---|---|
| 1.26.5 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.