Django: could not translate host name to address


I’m trying to connect a Django app to my Postgres instance. I’ve tried both the typical Django way, and using the dj-database-url library. My backend app and DB are in the same region.

When trying to connect to the internal render DB url, I get:

psycopg2.OperationalError: could not translate host name "dpg-ccudiaien0hklj3l3fa0-a" to address: Name or service not known

Here’s what the DB connection approaches look like:

dj-database-url (I know that Render provides a stringified version)

DB_NAME = os.getenv("DB_NAME", "db")
DB_USER = os.getenv("DB_USER", "kenny")
DB_HOST = os.getenv("DB_HOST", "localhost")
DB_PASSWORD = os.getenv("DB_PASSWORD", "")
DB_PORT = os.getenv("DB_PORT", 5432)

    'default': dj_database_url.parse(f'postgres://{DB_USER}:{DB_PASSWORD}@{DB_HOST}/{DB_NAME}')


    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": os.getenv("DB_NAME", "db"),
        "USER": os.getenv("DB_USER", "kenny"),
        "HOST": os.getenv("DB_HOST", "localhost"),
        "PASSWORD": os.getenv("DB_PASSWORD", ""),
        "PORT": os.getenv("DB_PORT", 5432),

Finally, the way it is shown in the “Deploy Django” docs:

    'default': dj_database_url.config(default=os.getenv('DATABASE_URL', ""), conn_max_age=60)

First 2 seem to have no issue locally, I’ve only tried the last on Render and I get a Django error:

django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

Anyway, I expect 1 of the first 2 to work regardless.

I am deploying to Render using a Docker container, not sure if it is something to do with the Docker networking? Any ideas what might be causing this?

Hi there,

Thanks for reaching out.

Thanks for confirming the service & DB are in the same region, but are they in the same account/team?

Private networking is limited to account/team as well as region. If this is cross-account/team you would need to use the external address. Alternatively, restore a backup into a DB in the same account/team as the calling service to allow private networking.

Kind regards


Thanks Alan. Turns out that I had created my DB was under what I guess is my account services, vs my services being under a team I had created. I’m new to Render - so not too sure what the use case is for having services under an account vs a team. Anyway, putting a DB under the team where I defined my services fixed things. Thanks for pointing that out!

Hey Kenny,

Glad to hear you resolved your issue.

Teams help isolate services & billing from other teams and your personal account. Teams also make it easier to collaborate with other people on the same services.

I use my personal account for hobby projects and spin up teams when I want to keep a set of specific services together with only access to each other on their private network.

Please let us know if we can assist any further.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.