Question

Django website DisallowedHost error

I followed the tutorial here: https://docs.digitalocean.com/tutorials/app-deploy-django-app/. I am getting the DisallowedHost error when trying to visit my web app at https://pulseapp-4av7x.ondigitalocean.app/.

I’ve tried adding the name of the site to allowed hosts to no avail. Right now I’m using DJANGO_ALLOWED_HOSTS as an environment variable, with ${APP_DOMAIN} as the value as the tutorial tells me to do, but it’s not working.

Any help with this would be appreciated.

Kind regards,

David


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi @,

Just to be sure, confirm you’ve configured the following part of the tutorial as well:

For your Django app to function, you need to set the following environment variables like so:

  • DJANGO_ALLOWED_HOSTS -> ${APP_DOMAIN}

    • This allows us to know the randomly generated URL that App Platform provides and provide it to our app
  • DATABASE_URL -> ${<NAME_OF_YOUR_DATABASE>.DATABASE_URL}

    • In this case, we’ll name our database db in the next step, so this should be ${db.DATABASE_URL}
  • DEBUG -> True

    • Set this to True for now to verify your app is functioning and set to False when it’s time for this app to be in production DJANGO_SECRET_KEY -> <A RANDOM SECRET KEY> You can either allow your app to generate this at every launch or pick a strong password with at least 32 characters to use as this key. Using a secure password generator is a good option for this
    • Don’t forget to click the Encrypt check box to ensure that your credentials are encrypted for safety