Reputation: 25
There are several of these threads, but none of them have an answer to my problem. I have a server hosting a website that is working perfectly if you direct there via the ip address, however I bought a dns, and I am trying to redirect the dns to the ip. I am using django 1.11.4 (the current pip install version). After setting up all of my DNS servers I can ping the server, but if I go to a browser and type in my dns I receive this error:
Environment:
Request Method: GET
Request URL: http://thefelpub.com/
Django Version: 1.11.4
Python Version: 2.7.12
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'pub')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _legacy_get_response
244. response = middleware_method(request)
File "/usr/local/lib/python2.7/dist-packages/django/middleware/common.py" in process_request
57. host = request.get_host()
File "/usr/local/lib/python2.7/dist-packages/django/http/request.py" in get_host
113. raise DisallowedHost(msg)
Exception Type: DisallowedHost at /
Exception Value: Invalid HTTP_HOST header: 'thefelpub.com'. You may need to add u'thefelpub.com' to ALLOWED_HOSTS.
I have added my dns to the ALLOWED_HOSTS=[] list, but no matter how many variations of the dns I try (including '*') I get the same error every time I try to get there.
Upvotes: 0
Views: 1910
Reputation: 374
Add the following to your ALLOWED_HOSTs = ['45.55.54.110', 'www.thefelpub.com', 'thefelpub.com']
, Save the settings.py file and then restart gunicorn, service gunicorn restart
to restart Django.
Upvotes: 0
Reputation: 22992
Has mentioned in the error message, you certainly need to add "thefelpub.com" in ALLOWED_HOSTS
.
ALLOWED_HOSTS = ['thefelpub.com']
or, not recommended:
ALLOWED_HOSTS = [*]
Upvotes: 1