Jump to solution
Verify

The Fix

pip install urllib3==1.25

Based on closed urllib3/urllib3 issue #1254 · 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
@@ -76,6 +76,23 @@ def tearDownClass(cls): cls.server_thread.join(0.1) + def assert_header_received( + self, + received_headers,
repro.py
(venv) ➜ ~ python Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin Type "help", "copyright", "credits" or "license" for more information. >> import urllib3 >> http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED') >> r = http.request('GET', 'https://github.com/') >> print r.status 200 >> r = http.request('GET', 'https://github.com./') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/request.py", line 66, in request **urlopen_kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/request.py", line 87, in request_encode_url return self.urlopen(method, url, **extra_kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/poolmanager.py", line 321, in urlopen response = conn.urlopen(method, u.request_uri, **kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/connectionpool.py", line 668, in urlopen **response_kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/connectionpool.py", line 668, in urlopen **response_kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/connectionpool.py", line 668, in urlopen **response_kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/connectionpool.py", line 639, in urlopen _stacktrace=sys.exc_info()[2]) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/util/retry.py", line 388, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='github.com.', port=443): Max retries exceeded with url: / (Caused by SSLError(CertificateError("hostname 'github.com.' doesn't match either of 'github.com', 'www.github.com'",),))
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: This fix is not suitable for domains where trailing dots are intentionally required for DNS resolution.\n\n

Why This Fix Works in Production

  • Trigger: (venv) ➜ ~ python
  • Mechanism: Hostname mismatch occurs due to trailing dots in domain names during SSL certificate validation
  • Why the fix works: Addresses the hostname mismatch error caused by trailing dots in domain names by ensuring that only fully qualified domain names (FQDNs) are used for DNS lookups, while stripping the trailing dot for other operations. (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

  • Shows up under Python 2.7.10 in real deployments (not just unit tests).
  • Hostname mismatch occurs due to trailing dots in domain names during SSL certificate validation
  • Surfaces as: (venv) ➜ ~ python

Proof / Evidence

  • GitHub issue: #1254
  • Fix PR: https://github.com/urllib3/urllib3/pull/1255
  • 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).

“Probably we should almost unconditionally do the dot-ectomy. It is likely to confuse most people to see it and also to cause latent bugs down…”
@Lukasa · 2017-09-01 · source
“@Lukasa, sounds good. I'll get to work on that; the unfortunate part is that we'll probably need to store the domain twice (once for DNS…”
@haikuginger · 2017-09-01 · source
“Nah, let's just create a property that does the transformation for us when we need it. 😁”
@Lukasa · 2017-09-01 · source
“LAZY EVALUATION FOR THE LAZY DEVELOPMENT GOD”
@haikuginger · 2017-09-01 · source

Failure Signature (Search String)

  • (venv) ➜ ~ python

Error Message

Stack trace
error.txt
Error Message ------------- (venv) ➜ ~ python Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin Type "help", "copyright", "credits" or "license" for more information. >> import urllib3 >> http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED') >> r = http.request('GET', 'https://github.com/') >> print r.status 200 >> r = http.request('GET', 'https://github.com./') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/request.py", line 66, in request **urlopen_kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/request.py", line 87, in request_encode_url return self.urlopen(method, url, **extra_kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/poolmanager.py", line 321, in urlopen response = conn.urlopen(method, u.request_uri, **kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/connectionpool.py", line 668, in urlopen **response_kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/connectionpool.py", line 668, in urlopen **response_kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/connectionpool.py", line 668, in urlopen **response_kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/connectionpool.py", line 639, in urlopen _stacktrace=sy ... (truncated) ...

Minimal Reproduction

repro.py
(venv) ➜ ~ python Python 2.7.10 (default, Jul 14 2015, 19:46:27) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin Type "help", "copyright", "credits" or "license" for more information. >> import urllib3 >> http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED') >> r = http.request('GET', 'https://github.com/') >> print r.status 200 >> r = http.request('GET', 'https://github.com./') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/request.py", line 66, in request **urlopen_kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/request.py", line 87, in request_encode_url return self.urlopen(method, url, **extra_kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/poolmanager.py", line 321, in urlopen response = conn.urlopen(method, u.request_uri, **kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/connectionpool.py", line 668, in urlopen **response_kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/connectionpool.py", line 668, in urlopen **response_kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/connectionpool.py", line 668, in urlopen **response_kw) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/connectionpool.py", line 639, in urlopen _stacktrace=sys.exc_info()[2]) File "/Users/karteek/venv/lib/python2.7/site-packages/urllib3/util/retry.py", line 388, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='github.com.', port=443): Max retries exceeded with url: / (Caused by SSLError(CertificateError("hostname 'github.com.' doesn't match either of 'github.com', 'www.github.com'",),))

Environment

  • Python: 2.7.10
  • urllib3: 1.22

What Broke

Users experience SSL errors when accessing domains with trailing dots, leading to failed requests.

Why It Broke

Hostname mismatch occurs due to trailing dots in domain names during SSL certificate validation

Fix Options (Details)

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

pip install urllib3==1.25

When NOT to use: This fix is not suitable for domains where trailing dots are intentionally required for DNS resolution.

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

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

  • This fix is not suitable for domains where trailing dots are intentionally required for DNS resolution.

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.
  • 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.25 Fixed

Related Issues

No related fixes found.

Sources

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