Django SuspiciousOperation: Invalid HTTP_HOST header (Add to ALLOWED_HOSTS)
Production hostname or Nginx proxy `Host` header is missing from `ALLOWED_HOSTS`.
Runs locally in browser
Free · No login
Independently Verified 2026-11-25
v4.1.0
Identifier: Django SuspiciousOperation
Platform: Python
Common Root Causes:
- Production hostname or Nginx proxy `Host` header is missing from `ALLOWED_HOSTS`.
Interactive Diagnostic Checklist
Verified Solutions:
- Add the exact production domain to `ALLOWED_HOSTS` (never `*` in production).
Safe Diagnostic Command:
Inspect `ALLOWED_HOSTS` in settings.py and Nginx `proxy_set_header Host $host;`
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.
Technical Explanation
Production hostname or Nginx proxy `Host` header is missing from `ALLOWED_HOSTS`. Recommended diagnostic: `Inspect `ALLOWED_HOSTS` in settings.py and Nginx `proxy_set_header Host $host;``. Remediation: Add the exact production domain to `ALLOWED_HOSTS` (never `*` in production).
Worked Examples
- Run `Inspect `ALLOWED_HOSTS` in settings.py and Nginx `proxy_set_header Host $host;`` 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-django-disallowedhost-400 · Independently verified: 2026-11-25