Reputation: 41
I'm running nginx, gunicorn and wagtail on Ubuntu 16.04. I am not using virtualenv. Both nginx and gunicorn seem to work just fine but when I go to my domain in a browser (let's say myweb.com) I get a disallowed host error.
This seems like a simple problem but I have already added myweb.com as an allowed host in base.py like so: ALLOWED_HOSTS = ['myweb.com']. It even says in the request information that myweb.com is an allowed host in the settings file but it seems like wagtail is just ignoring that. I also tried turning debug off in the dev settings but it still showed me the debug screen.
Edit: The specific error message is (with myweb.com instead of the actual domain):
DisallowedHost at /
Invalid HTTP_HOST header: 'myweb.com'. You may need to add 'myweb.com' to ALLOWED_HOSTS.
Request Method: GET
Request URL: http://myweb.com/
Django Version: 1.11.5
Exception Type: DisallowedHost
Exception Value: Invalid HTTP_HOST header: 'myweb.com'. You may need to add 'myweb.com' to ALLOWED_HOSTS.
Exception Location: /usr/local/lib/python3.5/dist-packages/django/http/request.py in get_host, line 113
Python Executable: /usr/bin/python3
Python Version: 3.5.2
Python Path:
['/home/fixgoats/myweb-root',
'/usr/local/bin',
'/usr/lib/python35.zip',
'/usr/lib/python3.5',
'/usr/lib/python3.5/plat-x86_64-linux-gnu',
'/usr/lib/python3.5/lib-dynload',
'/usr/local/lib/python3.5/dist-packages',
'/usr/lib/python3/dist-packages']
Traceback:
File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/usr/local/lib/python3.5/dist-packages/django/utils/deprecation.py" in __call__
138. response = self.process_request(request)
File "/usr/local/lib/python3.5/dist-packages/django/middleware/common.py" in process_request
57. host = request.get_host()
File "/usr/local/lib/python3.5/dist-packages/django/http/request.py" in get_host
113. raise DisallowedHost(msg)
Exception Type: DisallowedHost at /
Exception Value: Invalid HTTP_HOST header: 'myweb.com'. You may need to add 'myweb.com' to ALLOWED_HOSTS.
Request Information:
USER [unable to retrieve the current user]
GET No GET data
POST No POST data
FILES No FILES data
Settings Using settings module myweb.settings.dev
ALLOWED_HOSTS 'myweb.com'
There was quite a bit more information on the page but I think this is everything that might be relevant to the problem
Upvotes: 2
Views: 870
Reputation: 41
Gunicorn needed to be restarted. I don't know if it's supposed to work like this but on my setup it seems like Gunicorn always needs to be restarted to detect changes made to the project files.
Upvotes: 1