Report this

What is the reason for this report?

Django (App Platform) Migrate Command raises ERROR: "could not translate host name '[...]' to address: Temporary failure in name resolution'

Posted on April 18, 2022

I re-deployed my Django App on DO’s app platform but I am facing a new issue that I did not encounter before. Once successfully deployed, when I try to go into the console and run Django’s Migrate Command (python manage.py migrate) the following error is raised:

django.db.utils.OperationalError: could not translate host name “app-[…].db.ondigitalocean.com” to address: Temporary failure in name resolution

  1. The host name should be correct and in my App I use the following Environment Variables:
POSTGRES_DB: ${db.DATABASE}
POSTGRES_HOST: ${db.HOSTNAME}
POSTGRES_USER: ${db.USERNAME}
POSTGRES_PASSWORD: ${db.PASSWORD}
POSTGRES_PORT: ${db.PORT}
DATABASE_URL: ${db.DATABASE_URL}
  1. My Database configuration in settings.py:
DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql_psycopg2",
        "HOST": os.getenv("POSTGRES_HOST"),
        "NAME": os.getenv("POSTGRES_DB"),
        "PASSWORD": os.getenv("POSTGRES_PASSWORD"),
        "USER": os.getenv("POSTGRES_USER"),
        "PORT": os.getenv("POSTGRES_PORT", 0),
    }
}
  1. The Database is called db (default).

  2. I can connect to the database with the given connection details with my local PostgreSQL client.

I don’t know what else to try. Thanks in advance!



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!

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.

Same, any solution?

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.