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
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.