DisallowedHost Python Origin: Application & API Last updated 15 Oct 2026

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.

Exact message you may see Invalid HTTP_HOST headeradd to 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

  1. Add the domain(s): ALLOWED_HOSTS = ["example.com", "www.example.com"]
  2. Read from an env var per environment
  3. Configure the proxy to pass Host

Detailed fix by platform

Python

  1. ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "").split(",")

How to diagnose

  1. Host — Which host is in the message?
  2. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

1000 — Cloudflare Error 1000: DNS points to prohibited IP (Cloudflare)1000400 — HTTP 400 Bad Request (HTTP)400AADSTS90002 — AADSTS90002: Tenant 'x' not found (Azure)AADSTS90002AH00558 — Apache: AH00558: apache2: Could not reliably determine the server's fully qualified domain name (Nginx / Apache)AH00558api_version_invalid — API Error: Invalid or unsupported API version (API)api_version_invalidAzureWebJobsStorage — Azure Functions: Value cannot be null. (Parameter 'connectionString') / Missing value for AzureWebJobsStorage (Azure)AzureWebJobsStorageConnectionString property has not been initialized — InvalidOperationException: The ConnectionString property has not been initialized (.NET)ConnectionString prop…divergent branches — hint: You have divergent branches and need to specify how to reconcile them. (Git)divergent branchesDisallowe…

Explore the map of this error Full error map →

🧠 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.