tutorial icon indicating copy to clipboard operation
tutorial copied to clipboard

misconfiguration of the `ALLOWED_HOSTS` for pythonanywhere

Open edouard-lopez opened this issue 9 years ago • 9 comments

We found this issue during the latest @DjangoGirlsBdx.

Explanation

Deploying on pythonanywhere.com could trigger some error due to the misconfiguration of the ALLOWED_HOSTS. One solution is to edit mysite/settings.py to set

 ALLOWED_HOSTS=['*']

French

@pamplemousse : Il se peut que vous rencontriez une erreur au moment du déploiement sur pythonanywhere. Il faut modifier les ALLOWED_HOSTS dans settings.py avec votre url <nom d'utilisateur>.pythonanywhere.com. Faisable directement sur leur interface web, à faire locallement et à commiter avant de déployer.

@kardaj le problème avec ton fix c’est que le site ne marchera plus en local. On pourra aussi mettre ALLOWED_HOSTS=['*']

edouard-lopez avatar Mar 19 '17 12:03 edouard-lopez

I also had the problem with ALLOWED_HOSTS, and added '<my_username>.pythonanywhere.com', but not everyone encountered this error. Does anyone know the reason for that?

J'ai également eu le problème avec ALLOWED_HOSTS, et j'ai ajouté '<my_username> .pythonanywhere.com', mais pas tout le monde a rencontré cette erreur. Est-ce que quelqu'un connaît la raison pour laquelle?

gsimore avatar May 16 '17 17:05 gsimore

Hi, @gsimore and @edouard-lopez ! Could you two confirm to us which Python and Django version are you using?

We've also had this problem sporadically around here, but we have fixed with the solution you've mentioned.

rsip22 avatar Sep 13 '17 02:09 rsip22

The default was just changed and verified in the latest English version. I verified that worked for me so I'm going to close this. Please reopen this or a new issue if the problem persists.

ekohl avatar Jan 19 '18 16:01 ekohl

i have this problem what do i do

bazzscript avatar Jun 25 '19 14:06 bazzscript

someone answer me

bazzscript avatar Jun 25 '19 14:06 bazzscript

i have he above solutins but it efused

bazzscript avatar Jun 25 '19 14:06 bazzscript

i have he above solutins but it efused

What version of Django are you using?

I've had success using ALLOWED_HOSTS = ['*'] in Django 1.11 and later versions.

gsimore avatar Jun 25 '19 15:06 gsimore

I am tired of this error

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

settings.py:

ALLOWED_HOSTS=['subrahmanyam0326.pythonanywhere.com']

subrahmanyam0326 avatar Dec 17 '20 13:12 subrahmanyam0326

What is the value of your ALLOWED_HOSTS? It should include .pythonanywhere.com as instructed in https://tutorial.djangogirls.org/en/django_start_project/. Does that not work for you?

ekohl avatar Dec 17 '20 13:12 ekohl