Jump to solution
Details

The Fix

pip install urllib3==1.26.3

Based on closed urllib3/urllib3 issue #3015 · 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%.

Open PR/Commit
@@ -69,8 +69,6 @@ def add_stderr_logger(level=logging.DEBUG): # SecurityWarning's always go off by default. warnings.simplefilter("always", exceptions.SecurityWarning, append=True) -# SubjectAltNameWarning's should go off once per host -warnings.simplefilter("default", exceptions.SubjectAltNameWarning, append=True) # InsecurePlatformWarning's don't vary between requests, so we keep it default.
fix.md
Option A — Upgrade to fixed release\npip install urllib3==1.26.3\nWhen NOT to use: This fix is not applicable if the code relies on the warning's behavior.\n\n

Why This Fix Works in Production

  • Trigger: Importing urllib3.exceptions.SubjectAltNameWarning fails under 2.0.x
  • Mechanism: Removed the fallback on SubjectAltNameWarning in the match hostname function, addressing the import error under urllib3 2.0.x.
  • Why the fix works: Removed the fallback on SubjectAltNameWarning in the match hostname function, addressing the import error under urllib3 2.0.x. (first fixed release: 1.26.3).
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.8 in real deployments (not just unit tests).
  • Surfaces as: Traceback (most recent call last):

Proof / Evidence

  • GitHub issue: #3015
  • Fix PR: https://github.com/urllib3/urllib3/pull/2113
  • First fixed release: 1.26.3
  • 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.63

Discussion

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

“Pull request submitted for that library. https://github.com/hbldh/pybankid/pull/48 This code works for with test and production certificates, so I'm hopeful this patch or a variant of…”
@cthart · 2023-05-04 · confirmation · source
“Hello! And thank you for your report”
@pquentin · 2023-05-04 · source
“Yes, sorry if my last message was a bit cryptic: I'm not expecting a change to requests, but hopeful that just removing checks for this…”
@cthart · 2023-05-04 · source
“I'm trying to fix one of the libraries I'm using: https://github.com/hbldh/pybankid/blob/master/bankid/__init__.py”
@cthart · 2023-05-04 · source

Failure Signature (Search String)

  • Importing urllib3.exceptions.SubjectAltNameWarning fails under 2.0.x

Error Message

Stack trace
error.txt
Error Message ------------- Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name 'SubjectAltNameWarning' from 'urllib3.exceptions' (/home/colin/venv/lib/python3.8/site-packages/urllib3/exceptions.py)

Environment

  • Python: 3.8
  • urllib3: 1.26.15

What Broke

Importing SubjectAltNameWarning results in ImportError, breaking dependent libraries.

Fix Options (Details)

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

pip install urllib3==1.26.3

When NOT to use: This fix is not applicable if the code relies on the warning's behavior.

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

First fixed release: 1.26.3

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 if the code relies on the warning's behavior.

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

VersionStatus
1.26.3 Fixed

Related Issues

No related fixes found.

Sources

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