django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'x'. You may need to add 'x' to ALLOWED_HOSTS.
The request’s Host header isn’t listed in Django’s ALLOWED_HOSTS.
Invalid HTTP_HOST headeradd to ALLOWED_HOSTS Meaning
With DEBUG=False, Django only serves hosts in ALLOWED_HOSTS. New domains, server IPs, load balancer health checks and container hostnames must be added.
Common causes
- New domain/IP not in ALLOWED_HOSTS
- Load balancer health checks using the instance IP
- Proxy not forwarding the Host header
⚡ Quick fix
- Add the domain(s): ALLOWED_HOSTS = ["example.com", "www.example.com"]
- Read from an env var per environment
- Configure the proxy to pass Host
Detailed fix by platform
Python
ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "").split(",")
How to diagnose
- Host — Which host is in the message?
- Source — Real users or health checks?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Python
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 15 Oct 2026