The Fix
Upgrade to version 0.13.0 or later.
Based on closed encode/httpx issue #1171 · 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%.
@@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
+---
+name: Question
+about: Ask a question
import asyncio
from hypercorn.asyncio import serve
from hypercorn.config import Config
from starlette.applications import Starlette
from starlette.responses import JSONResponse
from starlette.routing import Route
async def homepage(request):
await asyncio.sleep(10)
return JSONResponse({})
app = Starlette(
routes=[
Route("/", homepage),
],
)
config = Config.from_mapping({})
config.bind = ["127.0.0.1:8001"]
asyncio.run(serve(app, config))
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\nUpgrade to version 0.13.0 or later.\nWhen NOT to use: This fix should not be used if the application requires a different connection management strategy.\n\nOption C — Workaround\nthat works for us.\nWhen NOT to use: This fix should not be used if the application requires a different connection management strategy.\n\n
Why This Fix Works in Production
- Trigger: loop.run_until_complete(main())
- Mechanism: The connection pool does not release connections after tasks complete when exceeding max_connections
- Why the fix works: Addresses the PoolTimeout issue when the number of tasks exceeds the max_connections limit in httpx. (first fixed release: 0.13.0).
- 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.6 in real deployments (not just unit tests).
- The connection pool does not release connections after tasks complete when exceeding max_connections
- Surfaces as: Traceback (most recent call last):
Proof / Evidence
- GitHub issue: #1171
- Fix PR: https://github.com/encode/httpcore/pull/880
- First fixed release: 0.13.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.39
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Until this is resolved, is there any reasonable way to work around this? Maybe we use our own asyncio.Semaphore like this:”
“I've a reproducer: Run this HTTP server script (a simple HTTP server that takes long to respond): Then run this client code: Looks like the…”
“Hello everyone, just want to make sure that this it what I'm looking for”
“I was going to mention the same. I also tested reading the whole response body (which should release the connection) and also closing the response…”
Failure Signature (Search String)
- loop.run_until_complete(main())
Error Message
Stack trace
Error Message
-------------
Traceback (most recent call last):
File "test_async.py", line 21, in <module>
loop.run_until_complete(main())
File "/Users/redacted/.pyenv/versions/3.6.9/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
return future.result()
File "test_async.py", line 16, in main
await asyncio.gather(*tasks)
File "/Users/redacted/.pyenv/versions/3.6.9/lib/python3.6/site-packages/httpx/_client.py", line 1416, in get
timeout=timeout,
File "/Users/redacted/.pyenv/versions/3.6.9/lib/python3.6/site-packages/httpx/_client.py", line 1242, in request
request, auth=auth, allow_redirects=allow_redirects, timeout=timeout,
File "/Users/redacted/.pyenv/versions/3.6.9/lib/python3.6/site-packages/httpx/_client.py", line 1273, in send
request, auth=auth, timeout=timeout, allow_redirects=allow_redirects,
File "/Users/redacted/.pyenv/versions/3.6.9/lib/python3.6/site-packages/httpx/_client.py", line 1302, in _send_handling_redirects
request, auth=auth, timeout=timeout, history=history
File "/Users/redacted/.pyenv/versions/3.6.9/lib/python3.6/site-packages/httpx/_client.py", line 1338, in _send_handling_auth
response = await self._send_single_request(request, timeout)
File "/Users/redacted/.pyenv/versions/3.6.9/lib/python3.6/site-packages/httpx/_client.py", line 1374, in _send_single_request
timeout=timeout.as_dict(),
File "/Users/reda
... (truncated) ...
Minimal Reproduction
import asyncio
from hypercorn.asyncio import serve
from hypercorn.config import Config
from starlette.applications import Starlette
from starlette.responses import JSONResponse
from starlette.routing import Route
async def homepage(request):
await asyncio.sleep(10)
return JSONResponse({})
app = Starlette(
routes=[
Route("/", homepage),
],
)
config = Config.from_mapping({})
config.bind = ["127.0.0.1:8001"]
asyncio.run(serve(app, config))
Environment
- Python: 3.6
- httpx: 0.25.0
Why It Broke
The connection pool does not release connections after tasks complete when exceeding max_connections
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
Upgrade to version 0.13.0 or later.
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Option C — Workaround Temporary workaround
that works for us.
Use only if you cannot change versions today. Treat this as a stopgap and remove once upgraded.
Fix reference: https://github.com/encode/httpcore/pull/880
First fixed release: 0.13.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the application requires a different connection management strategy.
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 |
|---|---|
| 0.13.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.