I am trying to host a django website on digital ocean through nginx. I have also mentioned domain in settings.py but getting error as below:

DisallowedHost at /
Invalid HTTP_HOST header: 'proutjournal.com'. You may need to add 'proutjournal.com' to ALLOWED_HOSTS.
Request Method: GET
Request URL:    http://proutjournal.com/
Django Version: 3.0.7
Exception Type: DisallowedHost
Exception Value:    
Invalid HTTP_HOST header: 'proutjournal.com'. You may need to add 'proutjournal.com' to ALLOWED_HOSTS.
Exception Location: /home/pranav/proutm/proutenv/lib/python3.6/site-packages/django/http/request.py in get_host, line 122
Python Executable:  /home/pranav/proutm/proutenv/bin/python
Python Version: 3.6.9
Python Path:    
['/home/pranav/proutm',
 '/home/pranav/proutm/proutenv/bin',
 '/usr/lib/python36.zip',
 '/usr/lib/python3.6',
 '/usr/lib/python3.6/lib-dynload',
 '/home/pranav/proutm/proutenv/lib/python3.6/site-packages']
Server time:    Wed, 8 Jul 2020 03:48:34 +0000
Traceback Switch to copy-and-paste view
/home/pranav/proutm/proutenv/lib/python3.6/site-packages/django/core/handlers/exception.py in inner
            response = get_response(request) …
▶ Local vars
/home/pranav/proutm/proutenv/lib/python3.6/site-packages/django/utils/deprecation.py in __call__
            response = self.process_request(request) …
▶ Local vars
/home/pranav/proutm/proutenv/lib/python3.6/site-packages/django/middleware/common.py in process_request
        host = request.get_host() …
▶ Local vars
/home/pranav/proutm/proutenv/lib/python3.6/site-packages/django/http/request.py in get_host
            raise DisallowedHost(msg) …
▶ Local vars 
edited by MattIPv4

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi there @pramod0021a,

I think that in your settings.py, you might have to specify both of your www and the non-www versions fo your domain name under the ALLOWED_HOSTS:

ALLOWED_HOSTS = ['your_server_domain_or_IP', 'yourdomain.com', 'www.yourdomain.com' . . .]

Let me know if this works!
Regards,
Bobby

Submit an Answer