1

This is the error I get when I visit 127.0.0.1:8000 in browser

DisallowedHost at /

Invalid HTTP_HOST header: '127.0.0.1:8000'. You may need to add '127.0.0.1' to ALLOWED_HOSTS.

Request Method:     GET
Request URL:    http://127.0.0.1:8000/
Django Version:     2.0.2
Exception Type:     DisallowedHost
Exception Value:    

Invalid HTTP_HOST header: '127.0.0.1:8000'. You may need to add '127.0.0.1' to ALLOWED_HOSTS.

Before you yell at me and tell that you should add the it in your ALLOWED_HOSTS fields in settings.py, I already did that as indicated Why is Django throwing error "DisallowedHost at /"?.

Settings.py field (I know if I put * then else everything is redundant, but still it gives me the same error.

ALLOWED_HOSTS = ['*','0.0.0.0','127.0.0.1']

This is my wsgi.py file

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "wordtutor.settings")
# Uncommenting following also does not solve the error
#os.environ["DJANGO_SETTINGS_MODULE"] =  "wordtutor.settings"
application = get_wsgi_application()

How can I solve this?

Edit : Python3.6 Django 2

Riken Shah
  • 3,022
  • 5
  • 29
  • 56
  • Are you sure you're editing the right `settings.py`? Try adding an error there and see if it's executed. – kichik Feb 15 '18 at 18:04
  • Yes, I am editing the same file. I get such an error too if i add anything random. line 29, in cdsjk NameError: name 'cdsjk' is not defined – Riken Shah Feb 15 '18 at 18:06
  • 2
    Try printing the value of `ALLOWED_HOSTS` at the end. Try removing middleware and apps one by one. Make sure there is no other settings file in the stack trace you for the error. – kichik Feb 15 '18 at 18:09
  • 2
    Ah..! Had another allowed_hosts below. how dumb of me. Thanks anyways. – Riken Shah Feb 15 '18 at 18:13

0 Answers0