misconfiguration of the `ALLOWED_HOSTS` for pythonanywhere
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_HOSTSdanssettings.pyavec 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=['*']
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?
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.
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.
i have this problem what do i do
someone answer me
i have he above solutins but it efused
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.
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']
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?