BlogDjango

DisallowedHost: Invalid HTTP_HOST header How to fix it.

Django only answers requests for addresses listed in ALLOWED_HOSTS. Add your Antideploy address, and your own domain if you attach one.

How the Agent API works
What you see
DisallowedHost at /
Invalid HTTP_HOST header: 'my-app.antideploy.app'. You may need to add
'my-app.antideploy.app' to ALLOWED_HOSTS.
  • What it meansYour address is not allowed
  • The fixAdd it to ALLOWED_HOSTS
  • AlsoCSRF_TRUSTED_ORIGINS for forms
  • Own domainAdd it too

What it means

Django checks the address of every request against a list called ALLOWED_HOSTS. When DEBUG is off, as it should be online, a request for an address that is not in the list is refused. Your Antideploy address is new, so it is not in your list yet.

How to fix it

  1. Add your address to ALLOWED_HOSTS

    Use the exact address, or the pattern .antideploy.app, which matches every address under it.

    settings.py
    ALLOWED_HOSTS = [".antideploy.app"]
    CSRF_TRUSTED_ORIGINS = ["https://*.antideploy.app"]
  2. Add CSRF_TRUSTED_ORIGINS for forms

    Without it, form submissions over HTTPS can be refused with a CSRF error.

  3. Add your own domain if you attach one

    Add www.verdant.in, or your own name, to both settings.

01Questions

Django host questions, answered.

Anything else? Write to us and a person answers.

support@antideploy.com
Is it safe to allow .antideploy.app?

It allows your Django app to answer requests for any address under it. An address under .antideploy.app that points to your app is yours. Use your exact address if you prefer to be strict.

Why did it work locally?

Locally Django allows localhost in debug mode.

Does this error cost anything?

No. It is a response from your app, and a deploy is not involved.

Deploy something. Start with one sentence.

Paste one sentence into your coding agent, click Approve once, and get a live link. No card, no trial clock.

Start from GitHub or a folder
Prompt copied Paste it into Claude Code, Codex or Cursor and press Enter.