The Fix
Fixes the regression introduced in aiohttp v3.13.1 regarding netrc authentication by ensuring that credentials are loaded correctly when the NETRC environment variable is not set.
Based on closed aio-libs/aiohttp issue #11713 · 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 @@
@@ -0,0 +1 @@
+Fixed loading netrc credentials from the default :file:`~/.netrc` (:file:`~/_netrc` on Windows) location when the :envvar:`NETRC` environment variable is not set -- by :user:`bdraco`.
diff --git a/CHANGES/11714.bugfix.rst b/CHANGES/11714.bugfix.rst
new file mode 120000
import aiohttp
import asyncio
async def main():
url = "https://httpbin.org/basic-auth/myuser/mypassword"
async with aiohttp.ClientSession(trust_env=True) as session:
async with session.get(url) as response:
response.raise_for_status()
asyncio.run(main())
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Apply the official fix\nFixes the regression introduced in aiohttp v3.13.1 regarding netrc authentication by ensuring that credentials are loaded correctly when the NETRC environment variable is not set.\nWhen NOT to use: This fix is not applicable if the NETRC environment variable is intentionally set for different behavior.\n\n
Why This Fix Works in Production
- Trigger: `aiohttp` v3.13.1 introduced a breaking change: the default .netrc file in the home directory is no longer used.
- Mechanism: Fixes the regression introduced in aiohttp v3.13.1 regarding netrc authentication by ensuring that credentials are loaded correctly when the NETRC environment variable is not set.
- 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.13 in real deployments (not just unit tests).
- Production symptom (often without a traceback): `aiohttp` v3.13.1 introduced a breaking change: the default .netrc file in the home directory is no longer used.
Proof / Evidence
- GitHub issue: #11713
- Fix PR: https://github.com/aio-libs/aiohttp/pull/11714
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.70
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.64
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“It must have regressed with https://github.com/aio-libs/aiohttp/pull/11634”
“I confirm I hit the issue and I also note that v3.13.0 works as expected.”
“If you set the NETRC environmental variable does the problem go away?”
“oh I see the issue. We have to take a performance hit to fix this but it is what it is”
Failure Signature (Search String)
- `aiohttp` v3.13.1 introduced a breaking change: the default .netrc file in the home directory is no longer used.
- ```python-traceback
Copy-friendly signature
Failure Signature
-----------------
`aiohttp` v3.13.1 introduced a breaking change: the default .netrc file in the home directory is no longer used.
```python-traceback
Error Message
Signature-only (no traceback captured)
Error Message
-------------
`aiohttp` v3.13.1 introduced a breaking change: the default .netrc file in the home directory is no longer used.
```python-traceback
Minimal Reproduction
import aiohttp
import asyncio
async def main():
url = "https://httpbin.org/basic-auth/myuser/mypassword"
async with aiohttp.ClientSession(trust_env=True) as session:
async with session.get(url) as response:
response.raise_for_status()
asyncio.run(main())
Environment
- Python: 3.13
Fix Options (Details)
Option A — Apply the official fix
Fixes the regression introduced in aiohttp v3.13.1 regarding netrc authentication by ensuring that credentials are loaded correctly when the NETRC environment variable is not set.
Fix reference: https://github.com/aio-libs/aiohttp/pull/11714
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if the NETRC environment variable is intentionally set for different behavior.
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
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.