The Fix
pip install urllib3==2.0.1
Based on closed urllib3/urllib3 issue #2999 · PR/commit linked
@@ -0,0 +1 @@
@@ -0,0 +1 @@
+avoid a ``ResourceWarning`` if ``assert_fingerprint`` or ``match_hostname`` fail
diff --git a/src/urllib3/connection.py b/src/urllib3/connection.py
index 1f13af0b63..9dc04fe099 100644
Option A — Upgrade to fixed release\npip install urllib3==2.0.1\nWhen NOT to use: Do not apply this fix if the application relies on the previous behavior of not closing sockets.\n\n
Why This Fix Works in Production
- Trigger: Potential regression in 2.0.0 (commit ea96fde9450b2d0d233f0414c7be0a75148fae8b)
- Mechanism: The SSLSocket was not closed properly when fingerprint verification failed, causing tests to hang
- Why the fix works: Ensures that the SSLSocket is closed if the assert_fingerprint or match_hostname fails, addressing the hanging issue in tests. (first fixed release: 2.0.1).
Why This Breaks in Prod
- The SSLSocket was not closed properly when fingerprint verification failed, causing tests to hang
- Production symptom (often without a traceback): Potential regression in 2.0.0 (commit ea96fde9450b2d0d233f0414c7be0a75148fae8b)
Proof / Evidence
- GitHub issue: #2999
- Fix PR: https://github.com/urllib3/urllib3/pull/2992
- First fixed release: 2.0.1
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.75
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.77
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“This is fixed by https://github.com/urllib3/urllib3/pull/2992”
“I was able to reproduce the hang wihout apm-agent-python: https://gist.github.com/pquentin/dddb538fe71d6a2b31e57918cda74047. Just run pytest -v, the second test will hang with urllib3 2.0.”
“So we have tests in urllib3 that do exactly that: test_verify_none_and_good_fingerprint and test_verify_none_and_bad_fingerprint”
Failure Signature (Search String)
- Potential regression in 2.0.0 (commit ea96fde9450b2d0d233f0414c7be0a75148fae8b)
- Previously the test `test_ssl_cert_pinning_fails` would succeed in 1.26.15, but fails by hanging in 2.0.0:
Copy-friendly signature
Failure Signature
-----------------
Potential regression in 2.0.0 (commit ea96fde9450b2d0d233f0414c7be0a75148fae8b)
Previously the test `test_ssl_cert_pinning_fails` would succeed in 1.26.15, but fails by hanging in 2.0.0:
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Potential regression in 2.0.0 (commit ea96fde9450b2d0d233f0414c7be0a75148fae8b)
Previously the test `test_ssl_cert_pinning_fails` would succeed in 1.26.15, but fails by hanging in 2.0.0:
Environment
- urllib3: 2.0
What Broke
Tests hang indefinitely during SSL certificate verification, impacting CI/CD pipelines.
Why It Broke
The SSLSocket was not closed properly when fingerprint verification failed, causing tests to hang
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install urllib3==2.0.1
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/2992
First fixed release: 2.0.1
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not apply this fix if the application relies on the previous behavior of not closing sockets.
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 |
|---|---|
| 2.0.1 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.