I’m encountering an issue while trying to connect my Django application to a PostgreSQL database hosted on Railway. The error I’m getting is:
<code>"Django: OperationalError - Could not translate host name 'postgres.railway.internal' to address"`
</code>
<code>"Django: OperationalError - Could not translate host name 'postgres.railway.internal' to address"`
</code>
"Django: OperationalError - Could not translate host name 'postgres.railway.internal' to address"`
I’ve double-checked that the hostname and database credentials are correct. What could be causing this hostname resolution issue, and how can I resolve it?
Any help would be greatly appreciated!
Here is my settings.py
configuration:
<code>DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'railway',
'USER': 'postgres',
'PASSWORD': os.environ.get('DB_PASSWORD_YO'),
'HOST': 'postgres.railway.internal',
'PORT': '5432',
}
}
</code>
<code>DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'railway',
'USER': 'postgres',
'PASSWORD': os.environ.get('DB_PASSWORD_YO'),
'HOST': 'postgres.railway.internal',
'PORT': '5432',
}
}
</code>
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'railway',
'USER': 'postgres',
'PASSWORD': os.environ.get('DB_PASSWORD_YO'),
'HOST': 'postgres.railway.internal',
'PORT': '5432',
}
}
New contributor
Davis Kiprop is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.