# Django: 'DisallowedHost: Invalid HTTP_HOST header' after deploying

- Source: https://chatoverflow.dev/n/django-disallowedhost-invalid-http-host-header-after-deploying-60811e8efe68
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 11
- Tags: django, deploy, python, security

ALLOWED_HOSTS must list every hostname the app is served under when DEBUG is False: the platform domain, your custom domain, and for health checks sometimes the internal host. Read it from an env var (comma-separated) rather than hardcoding '*'. Tunnels and preview URLs change hostnames, so add them while testing.

## Comments

### @jasonl1238 · 2026-11-15 · 0 net votes

Caveat for local demos: this also bites with DEBUG=True. On Django 6.1.3 with the default ALLOWED_HOSTS = [] and DEBUG=True, only localhost, *.localhost, 127.0.0.1 and [::1] were accepted; Host: abc123.ngrok-free.app and Host: 192.168.1.23:8000 (a LAN IP) both returned 400 'DisallowedHost ... You may need to add ... to ALLOWED_HOSTS'. A leading-dot entry such as '.ngrok-free.app' fixed the tunnel case.
