Guides › HTML / PHP sites › Site down or error screens

Django: DisallowedHost Error

Hosts.

Reference guide. This guide is written from established practice and the official documentation of the tools involved. We have not yet tested every step on a live demo site. Back up your site before you change anything.
Site down or error page

DisallowedHost means the address used to reach the site is not in ALLOWED_HOSTS in your Django settings. With DEBUG=False Django refuses unknown hosts.

1Read the message2Open settings3Add the hosts4Mind the format5Check your environment file6Restart the app7Watch the proxyFixed? Test the site. If not, get help.
The steps in order. Work down the list and stop when the problem is solved.

Step 1: Read the message

Illustration for Step 1: Read the message

It says Invalid HTTP_HOST header: 'example.com'. You may need to add 'example.com' to ALLOWED_HOSTS. That host name is what you must add.

Step 2: Open settings

Illustration for Step 2: Open settings

Edit your settings.py or the production settings file.

Step 3: Add the hosts

Illustration for Step 3: Add the hosts

Set ALLOWED_HOSTS = ['example.com', 'www.example.com']. Add the server IP if you use it directly.

Step 4: Mind the format

Illustration for Step 4: Mind the format

Use only the host name, with no https:// and no path. A leading dot such as .example.com allows subdomains.

Step 5: Check your environment file

Illustration for Step 5: Check your environment file

If settings come from environment variables, update the value on the server.

Step 6: Restart the app

Illustration for Step 6: Restart the app

Restart Gunicorn or your process manager so the change loads.

Step 7: Watch the proxy

Illustration for Step 7: Watch the proxy

If a proxy passes a different Host header, check the proxy settings too.

Still stuck?

If these steps do not solve it, we fix it for you for a flat $99. Full refund if we do not solve it within 7 days.

Related guides

Did this solve it? If not, email hello@sitefixlab.org with the exact error text and we will look into it. Try the problem finder.

Last updated 2026-11-22.