Tag: Django

Django ALLOWED_HOSTS
01/08/2019
After you installed Django and wanted to view it from another local machine you got this error:
DisallowedHost at / Invalid HTTP_HOST header: ‘192.168.3.20’. You may need to add u’192.168.3.20′ to ALLOWED_HOSTS.
I use this to work around it.
Run as:
1 |
python3 manage.py runserver 0:8000 |
Open the settings:
1 |
nano settings.py |
Change and add:
1 2 |
ALLOWED_HOSTS = ['localhost','127.0.0.1'] ALLOWED_HOSTS += ['192.168.3.{}'.format(i) for i in range(256)] |
Now everything and anyone on your local network should have acces to the website.
^that’s also a big warning!
Share the post "Django ALLOWED_HOSTS"