Single click DO django droplet rejects domain name

Posted November 26, 2018 2.8k views
DjangoApplicationsUbuntu 18.04

I have set up a single click droplet with Django. Access works properly using the ip address ( but not the newly assigned domain name (

Although the debugging information provided by Django suggests the site name be added to the ALLOWED HOSTS in the file, that file uses the ipaddresses() function to determine the hosts at run time.

As a fix I have tried this: I added the domain names to the nginx configuration file (copied the original /sites-available/django file as /sites-available/django_1 and linked this file to the /sites-enabled folder (removed the django file in this folder). This did not correct the problem.

How do I fix this?



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

Hey friend,

Try changing the ALLOWED_HOSTS value from the ip _ addresses (removed spaces for markdown) function to that of your domain. If you’re defining that at the top of the file and then it’s being redefined by the function later, you can change the later instance of it to this:

ALLOWED_HOSTS += ip_addresses()

Hope that helps :)


  • Thank you, Jarland this is very helpful.
    BTW, the script in the Django droplet includes the ip _ addresses() function twice - once at the beginning and again at the end. I’m guessing this is an oversight, and it doesn’t appear to do any harm…can you see any other reason why this might be so?

    Thanks again.