Deployment Error: Disallowed Host at-

Posted July 8, 2020 4.5k views

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

DisallowedHost at /
Invalid HTTP_HOST header: ''. You may need to add '' to ALLOWED_HOSTS.
Request Method: GET
Request URL:
Django Version: 3.0.7
Exception Type: DisallowedHost
Exception Value:    
Invalid HTTP_HOST header: ''. You may need to add '' to ALLOWED_HOSTS.
Exception Location: /home/pranav/proutm/proutenv/lib/python3.6/site-packages/django/http/ in get_host, line 122
Python Executable:  /home/pranav/proutm/proutenv/bin/python
Python Version: 3.6.9
Python Path:    
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/ in inner
            response = get_response(request) …
▶ Local vars
/home/pranav/proutm/proutenv/lib/python3.6/site-packages/django/utils/ in __call__
            response = self.process_request(request) …
▶ Local vars
/home/pranav/proutm/proutenv/lib/python3.6/site-packages/django/middleware/ in process_request
        host = request.get_host() …
▶ Local vars
/home/pranav/proutm/proutenv/lib/python3.6/site-packages/django/http/ 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.

Submit an Answer
1 answer

Hi there @pramod0021a,

I think that in your, 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', '', '' . . .]

Let me know if this works!