The Fix
Upgrade to version 0.7.2 or later.
Based on closed encode/httpx issue #198 · PR/commit linked
@@ -32,10 +32,10 @@
from .interfaces import (
AsyncDispatcher,
- BaseReader,
- BaseWriter,
BaseBackgroundManager,
from httpx import Client
client = Client()
r = client.request("GET", "https://www.howsmyssl.com/a/check") # Completes successfully
r = client.request("GET", "https://howsmyssl.com/a/check") # Sends a redirect to 'www.howsmyssl.com' but then errors?
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.7.2 or later.\nWhen NOT to use: Do not apply this fix if the application relies on the 'Host' header for redirect handling.\n\n
Why This Fix Works in Production
- Trigger: Our redirect loop detection or redirects in general is broken somehow because this shouldn't error out:
- Mechanism: The 'Host' header was not removed on redirects when the URL origin changed, causing infinite loops
- Why the fix works: Removes the 'Host' header on redirects if the URL origin has changed, addressing the infinite redirect loop issue. (first fixed release: 0.7.2).
Why This Breaks in Prod
- The 'Host' header was not removed on redirects when the URL origin changed, causing infinite loops
- Production symptom (often without a traceback): Our redirect loop detection or redirects in general is broken somehow because this shouldn't error out:
Proof / Evidence
- GitHub issue: #198
- Fix PR: https://github.com/encode/httpx/pull/199
- First fixed release: 0.7.2
- 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.71
Verified Execution
We executed the runnable minimal repro in a temporary environment and captured exit codes + logs.
- Status: PASS
- Ran: 2026-02-11T16:52:29Z
- Package: httpx
- Fixed: 0.7.2
- Mode: fixed_only
- Outcome: ok
Logs
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Our redirect loop detection or redirects in general is broken somehow because this shouldn't error out:”
Failure Signature (Search String)
- Our redirect loop detection or redirects in general is broken somehow because this shouldn't error out:
- r = client.request("GET", "https://www.howsmyssl.com/a/check") # Completes successfully
Copy-friendly signature
Failure Signature
-----------------
Our redirect loop detection or redirects in general is broken somehow because this shouldn't error out:
r = client.request("GET", "https://www.howsmyssl.com/a/check") # Completes successfully
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Our redirect loop detection or redirects in general is broken somehow because this shouldn't error out:
r = client.request("GET", "https://www.howsmyssl.com/a/check") # Completes successfully
Minimal Reproduction
from httpx import Client
client = Client()
r = client.request("GET", "https://www.howsmyssl.com/a/check") # Completes successfully
r = client.request("GET", "https://howsmyssl.com/a/check") # Sends a redirect to 'www.howsmyssl.com' but then errors?
What Broke
Clients experienced infinite redirect loops leading to request failures.
Why It Broke
The 'Host' header was not removed on redirects when the URL origin changed, causing infinite loops
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
Upgrade to version 0.7.2 or later.
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/encode/httpx/pull/199
First fixed release: 0.7.2
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not apply this fix if the application relies on the 'Host' header for redirect handling.
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.7.2 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.