FastAPI / Uvicorn Unreachable Outside Docker Container (Bound to 127.0.0.1)
Uvicorn defaults to `--host 127.0.0.1`, blocking Docker port-forwarding from the host.
Runs locally in browser
Free · No login
Independently Verified 2026-11-25
v4.1.0
Identifier: FastAPI / Uvicorn Unreachable Outside Docker Container (Bound to 127.0.0.1)
Platform: Python
Common Root Causes:
- Uvicorn defaults to `--host 127.0.0.1`, blocking Docker port-forwarding from the host.
Interactive Diagnostic Checklist
Verified Solutions:
- Pass `--host 0.0.0.0 --port 8000` inside container while publishing `-p 127.0.0.1:8000:8000` on host.
Safe Diagnostic Command:
ss -tulpn inside container
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.
Technical Explanation
Uvicorn defaults to `--host 127.0.0.1`, blocking Docker port-forwarding from the host. Recommended diagnostic: `ss -tulpn inside container`. Remediation: Pass `--host 0.0.0.0 --port 8000` inside container while publishing `-p 127.0.0.1:8000:8000` on host.
Worked Examples
- Run `ss -tulpn inside container` to verify root cause before applying the remediation.
Limitations & Assumptions
- Always verify configuration changes in staging or with dry-run flags (e.g. `nginx -t`) before reloading production services.
Source References & Verification
Resource ID: err-py-uvicorn-bind-0000-docker · Independently verified: 2026-11-25