PythonAnywhere Forums

Error during 'Deploy!' part of tutorial-- "Invalid HTTP_HOST header"

I get to the very end of this part of the tutorial, reload the web page and load it, and receive this error:

DisallowedHost at /Invalid HTTP_HOST header: ''. You may need to add '' to ALLOWED_HOSTS.

I've used my own names for the databases/virtual environments so I've double/triple checked that I didn't make any mistakes when typing out paths.
I've also tried updating 'ALLOWED_HOSTS' in my local computer as suggested, pushed it to GitHub, and pulled it to the live server using the PythonAnywhere console. Still same error.
What could be the issue?

edit: typo

Did you reload you web app after pulling to PythonAnywhere?

I did.

Now that I remember, I did skip ONE step when following the tutorial again for pushing/pulling: I skipped the 'git remote add origin' command as I thought this was only necessary once. Should I have executed this command before 'git push -u origin master'?

edit: if it makes any difference--I am using pyenv on my local computer, and virtualenv on the PythonAnywhere console. I can't think of anything else that I'm doing differently and messing up :/ please help!

It seems likely that, if you haven't set up git correctly, then pushing and pulling code is unlikely to work the way you expect. Did you check that the code was what you expected after the push?

I checked that the changes were made and correct on github, but cannot find a way to make sure that it was updated onto PythonAnywhere.
The last time I gitcloned on the PA's bash, I received the message:

fatal: destination path 'dg-blog' already exists and is not an empty directory.

And as a matter of fact, I was just now going through a git tutorial. I do believe I had it set up correctly. What else might I try?

edit: Also, then would it be safe to assume that the fix to the error is in fact the need to add '' into the 'ALLOWED_HOSTS' list in
This was not mentioned in the tutorial.

edit2: Is all that it takes to 'pull' into PA simply the 'git clone' command while in my venv? Or should I have not been in a venv as is implied by the order within the tutorial?

You can look at your files in Files tab or you can use an editor in a bash console to look at them.

Yes, it is necessary to set ALLOWED_HOSTS correctly.

you were right all along. I had not been using the correct git commands to update it onto PA. Got it to work. Thank you glenn!

Im having same issue , guys

I checked the error log and this was the error: Invalid HTTP_HOST header: ''. You may need to add '' to ALLOWED_HOSTS.

How do i go about it? someone please help

Sorry for the slow response! What setting do you have for ALLOWED_HOSTS in your file?

I am receiving the same error: Invalid HTTP_HOST header: ''. You may need to add '' to ALLOWED_HOSTS. Can anybody kindly tell us how to resolve this issue.

you should go to and add to the allowed_hosts variable (and then reload your webapp)