DisallowedHost at /: Invalid HTTP_HOST header


I'm following this tutorial ( and I keep getting a DisallowedHost error. (Screenshot:

In, added '' to the ALLOWED_HOSTS list, and I made sure to include it in quotation marks and keep the brackets. I even added it to, at line 113 (indicated in the error message).

Screenshots: and

I also committed the changes to Git, and I double-checked the repository to make sure that the URL was added to ALLOWED_HOSTS. (It was.) And of course, I reuploaded the changes on PythonAnywhere too.

After all that, I'm still getting the error! It's really frustrating, and I don't know what else to do. Any help would be much appreciated!

can you open up the file on pythonanywhere, and copy and paste into here what it says for ALLOWED_HOSTS?

You hit the nail on the head!

ALLOWED_HOSTS = ['', '<your_username>']

I had to replace <your-username> with my username. Thanks so much!

I didn't know that the settings file online could be different. Do you know why that happened?

Because locally you're running the dev server or with debug enabled.

So if I set DEBUG = False, that would also work? Isn't that an important security feature?

What do you mean when you say I'm running the dev server locally - as in, on my system? Even though I updated the on my computer, the changes didn't get reflected in the file on PythonAnywhere...?

Thanks for your help Harry, and thank you too Glenn, for your explanation! I appreciate it.

Yes, DEBUG=False is an important security feature and so is ALLOWED_HOSTS.

I assumed that you were wondering about why you got the ALLOWED_HOSTS error on PythonAnywhere and not when you were working on your machine.

How did you resolve this? I am too having the same problem. I am deploying my app for the first time and it is throwing the same error even after adding the same in

I don't get that error when I go to -- did you work out what the problem was?