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: 'simonsterj.pythonanywhere.com'. You may need to add 'simonsterj.pythonanywhere.com' 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 'simonsterj.pythonanywhere.com' into the 'ALLOWED_HOSTS' list in settings.py?
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: 'community.pythonanywhere.com'. You may need to add 'community.pythonanywhere.com' 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 settings.py file?

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

you should go to settings.py and add route2sabya.pythonanywhere.com to the allowed_hosts variable (and then reload your webapp)

I had the same error, so I added bakagaijinhakka.pythonanywhere.com to my ALLOWED_HOSTS. Now it returns me the following errors

2017-04-10 14:27:32,716 :Error running WSGI application
2017-04-10 14:27:32,717 :ImportError: No module named 'bakagaijinhakka'
2017-04-10 14:27:32,717 :  File "/var/www/bakagaijinhakka_pythonanywhere_com_wsgi.py", line 13, in <module>

I had the same error, so I added bakagaijinhakka.pythonanywhere.com to my ALLOWED_HOSTS. Now it returns me the following errors

2017-04-10 14:27:32,716 :Error running WSGI application
2017-04-10 14:27:32,717 :ImportError: No module named 'bakagaijinhakka'
2017-04-10 14:27:32,717 :  File "/var/www/bakagaijinhakka_pythonanywhere_com_wsgi.py", line 13, in <module>

Hi there,

The full error message is something like this:

2017-04-10 14:47:58,650 :Error running WSGI application
2017-04-10 14:47:58,662 :ImportError: No module named 'bakagaijinhakka'
2017-04-10 14:47:58,662 :  File "/var/www/bakagaijinhakka_pythonanywhere_com_wsgi.py", line 13, in <module>
2017-04-10 14:47:58,662 :    application = DjangoWhiteNoise(get_wsgi_application())
2017-04-10 14:47:58,662 :
2017-04-10 14:47:58,662 :  File "/home/BakaGaijinHakka/tutorial/myvenv/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
2017-04-10 14:47:58,662 :    django.setup(set_prefix=False)
2017-04-10 14:47:58,663 :
2017-04-10 14:47:58,663 :  File "/home/BakaGaijinHakka/tutorial/myvenv/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
2017-04-10 14:47:58,663 :    apps.populate(settings.INSTALLED_APPS)
2017-04-10 14:47:58,663 :
2017-04-10 14:47:58,663 :  File "/home/BakaGaijinHakka/tutorial/myvenv/lib/python3.5/site-packages/django/apps/registry.py", line 85, in populate
2017-04-10 14:47:58,663 :    app_config = AppConfig.create(entry)
2017-04-10 14:47:58,663 :
2017-04-10 14:47:58,663 :  File "/home/BakaGaijinHakka/tutorial/myvenv/lib/python3.5/site-packages/django/apps/config.py", line 120, in create
2017-04-10 14:47:58,664 :    mod = import_module(mod_path)
2017-04-10 14:47:58,664 :***************************************************
2017-04-10 14:47:58,664 :If you're seeing an import error and don't know why,
2017-04-10 14:47:58,664 :we have a dedicated help page to help you debug: 
2017-04-10 14:47:58,664 :https://help.pythonanywhere.com/pages/DebuggingImportError/
2017-04-10 14:47:58,664 :***************************************************

What do you see if you follow the instructions on the linked help page?

it's