What I'm trying to do: Deploy my django app to render.com with a postgres database. I'm following the render guide: Getting Started with Django on Render.
Problem: I am getting a build failed log error saying the following: django.db.utils.OperationalError: could not translate host name "***" to address: Name or service not known
(I have omitted the actual host name here).
What research I have done: I have searched the error extensively, however all of the highly rated solutions I have encountered so far are based on using Docker like this which I am not using.
settings.py (snippet):
import dj_database_url
DEBUG = 'RENDER' not in os.environ
if DEBUG:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
if not DEBUG:
DATABASES = {
'default': dj_database_url.config(
default=os.environ.get('DATABASE_URL'),
)
}
In my render.com environmental variables, DATABASE_URL
is saved with the postgres URL given by render which includes the database name, hostname, username and password. It follows this format: postgres://USER:PASSWORD@INTERNAL_HOST:PORT/DATABASE