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.
Seen on:
Python
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 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026