The Fix
Upgrade to version 0.31.1 or later.
Based on closed Kludex/uvicorn issue #2477 · 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%.
@@ -56,6 +56,7 @@ def make_httpx_client(
_TRUSTED_NOTHING: list[str] = []
_TRUSTED_EVERYTHING = "*"
+_TRUSTED_EVERYTHING_LIST = ["*"]
_TRUSTED_IPv4_ADDRESSES = "127.0.0.1, 10.0.0.1"
_TRUSTED_IPv4_NETWORKS = ["127.0.0.0/8", "10.0.0.0/8"]
Option A — Upgrade to fixed release\nUpgrade to version 0.31.1 or later.\nWhen NOT to use: Do not use this fix if you require strict host validation for security.\n\n
Why This Fix Works in Production
- Trigger: --forwarded-allow-ips '*' broken in combination with gunicorn
- Mechanism: The check for wildcard in trusted hosts changed from 'in' to '==' causing misbehavior
- Why the fix works: Adds support for `[*]` in trusted hosts, fixing the parsing for always trust case when using `--forwarded-allow-ips` with gunicorn and uvicorn. (first fixed release: 0.31.1).
- 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
- The check for wildcard in trusted hosts changed from 'in' to '==' causing misbehavior
- Production symptom (often without a traceback): --forwarded-allow-ips '*' broken in combination with gunicorn
Proof / Evidence
- GitHub issue: #2477
- Fix PR: https://github.com/encode/uvicorn/pull/2480
- First fixed release: 0.31.1
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.75
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.80
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“- Closed on https://github.com/encode/uvicorn/pull/2480”
“Turns out gunicorn is parsing forwarded_allow_ips command line option and then putting its values into a list before handing it over to uvicorn's worker as…”
Failure Signature (Search String)
- --forwarded-allow-ips '*' broken in combination with gunicorn
Copy-friendly signature
Failure Signature
-----------------
--forwarded-allow-ips '*' broken in combination with gunicorn
Error Message
Signature-only (no traceback captured)
Error Message
-------------
--forwarded-allow-ips '*' broken in combination with gunicorn
What Broke
Requests with --forwarded-allow-ips '*' fail to be trusted, leading to access issues.
Why It Broke
The check for wildcard in trusted hosts changed from 'in' to '==' causing misbehavior
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
Upgrade to version 0.31.1 or later.
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Option D — Guard side-effects with OnceOnly Guardrail for side-effects
Mitigate duplicate external side-effects under retries/timeouts/agent loops by gating the operation before calling external systems.
- Place OnceOnly between your code/agent and real side-effects (Stripe, emails, CRM, APIs).
- Use a stable key per side-effect (e.g., customer_id + action + idempotency_key).
- Fail-safe: configure fail-open vs fail-closed based on blast radius and spend risk.
Show example snippet (optional)
from onceonly import OnceOnly
import os
once = OnceOnly(api_key=os.environ["ONCEONLY_API_KEY"], fail_open=True)
# Stable idempotency key per real side-effect.
# Use a request id / job id / webhook delivery id / Stripe event id, etc.
event_id = "evt_..." # replace
key = f"stripe:webhook:{event_id}"
res = once.check_lock(key=key, ttl=3600)
if res.duplicate:
return {"status": "already_processed"}
# Safe to execute the side-effect exactly once.
handle_event(event_id)
Fix reference: https://github.com/encode/uvicorn/pull/2480
First fixed release: 0.31.1
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- Do not use this fix if you require strict host validation for security.
- Do not use this to hide logic bugs or data corruption. Use it to block duplicate external side-effects and enforce tool permissions/spend caps.
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.
Version Compatibility Table
| Version | Status |
|---|---|
| 0.31.1 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.