The Fix
pip install urllib3==2.2.0
Based on closed urllib3/urllib3 issue #2770 · PR/commit linked
@@ -511,9 +511,10 @@ def _make_request(
except OSError as e:
# MacOS/Linux
- # EPROTOTYPE is needed on macOS
+ # EPROTOTYPE and ECONNRESET are needed on macOS
# https://erickt.github.io/blog/2014/11/19/adventures-in-debugging-a-potential-osx-kernel-bug/
Traceback (most recent call last):
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 732, in urlopen
httplib_response = self._make_request(
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 444, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connection.py", line 355, in request
self.send(chunk)
File "/Users/runner/hostedtoolcache/Python/3.8.14/x64/lib/python3.8/http/client.py", line 972, in send
self.sock.sendall(data)
ConnectionResetError: [Errno 54] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/runner/work/urllib3/urllib3/test/with_dummyserver/test_socketlevel.py", line 2023, in test_ignore_broken_pipe_errors
r = pool.request("POST", "/", body=buf)
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/_request_methods.py", line 117, in request
return self.request_encode_body(
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/_request_methods.py", line 216, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 799, in urlopen
retries = retries.increment(
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/util/retry.py", line 467, in increment
raise reraise(type(error), error, _stacktrace)
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/util/util.py", line 36, in reraise
raise value.with_traceback(tb)
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 732, in urlopen
httplib_response = self._make_request(
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 444, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connection.py", line 355, in request
self.send(chunk)
File "/Users/runner/hostedtoolcache/Python/3.8.14/x64/lib/python3.8/http/client.py", line 972, in send
self.sock.sendall(data)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
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==2.2.0\nWhen NOT to use: Do not apply this fix if running on non-macOS environments.\n\n
Why This Fix Works in Production
- Trigger: httplib_response = self._make_request(
- Mechanism: ConnectionResetError occurs due to improper error handling for connection resets on macOS
- Why the fix works: Fixes the TestBrokenPipe test that fails on macOS 12 by adjusting error handling for connection resets. (first fixed release: 2.2.0).
Why This Breaks in Prod
- Shows up under Python 3.8 in real deployments (not just unit tests).
- ConnectionResetError occurs due to improper error handling for connection resets on macOS
- Surfaces as: Traceback (most recent call last):
Proof / Evidence
- GitHub issue: #2770
- Fix PR: https://github.com/urllib3/urllib3/pull/3246
- First fixed release: 2.2.0
- 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.28
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“My early 2015 MacBook is unfortunately stuck on macOS 11 so I can't simply help with debugging. I'm considering using a service like https://www.scaleway.com/en/hello-m1/ where…”
Failure Signature (Search String)
- httplib_response = self._make_request(
Error Message
Stack trace
Error Message
-------------
Traceback (most recent call last):
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 732, in urlopen
httplib_response = self._make_request(
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 444, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connection.py", line 355, in request
self.send(chunk)
File "/Users/runner/hostedtoolcache/Python/3.8.14/x64/lib/python3.8/http/client.py", line 972, in send
self.sock.sendall(data)
ConnectionResetError: [Errno 54] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/runner/work/urllib3/urllib3/test/with_dummyserver/test_socketlevel.py", line 2023, in test_ignore_broken_pipe_errors
r = pool.request("POST", "/", body=buf)
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/_request_methods.py", line 117, in request
return self.request_encode_body(
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/_request_methods.py", line 216, in request_encode_body
return self.urlopen(method, url, **extra_kw)
F
... (truncated) ...
Minimal Reproduction
Traceback (most recent call last):
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 732, in urlopen
httplib_response = self._make_request(
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 444, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connection.py", line 355, in request
self.send(chunk)
File "/Users/runner/hostedtoolcache/Python/3.8.14/x64/lib/python3.8/http/client.py", line 972, in send
self.sock.sendall(data)
ConnectionResetError: [Errno 54] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/runner/work/urllib3/urllib3/test/with_dummyserver/test_socketlevel.py", line 2023, in test_ignore_broken_pipe_errors
r = pool.request("POST", "/", body=buf)
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/_request_methods.py", line 117, in request
return self.request_encode_body(
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/_request_methods.py", line 216, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 799, in urlopen
retries = retries.increment(
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/util/retry.py", line 467, in increment
raise reraise(type(error), error, _stacktrace)
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/util/util.py", line 36, in reraise
raise value.with_traceback(tb)
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 732, in urlopen
httplib_response = self._make_request(
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 444, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/Users/runner/work/urllib3/urllib3/.nox/test-3-8/lib/python3.8/site-packages/urllib3/connection.py", line 355, in request
self.send(chunk)
File "/Users/runner/hostedtoolcache/Python/3.8.14/x64/lib/python3.8/http/client.py", line 972, in send
self.sock.sendall(data)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
Environment
- Python: 3.8
What Broke
Test failures in CI due to connection resets on macOS 12.
Why It Broke
ConnectionResetError occurs due to improper error handling for connection resets on macOS
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
pip install urllib3==2.2.0
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/3246
First fixed release: 2.2.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not apply this fix if running on non-macOS environments.
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 |
|---|---|
| 2.2.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.