skip to Main Content
django.db.utils.OperationalError: could not translate host name "postgres.railway.internal" to address: nodename nor servname provided, or not known

My Django project was working great until I changed the setting.py file to deploy it in Railway, using the variables Railway provides.

Since then, I can’t runserv or migrate, that I get this error…

Here are the database settings changed to use the Railway variables:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'railway',
        'USER': 'postgres',
        'PASSWORD': DB_PASSWORD_RAIL,
        'HOST': 'postgres.railway.internal',
        'PORT': '5432',
    }
}

Error when I runserver or migrate:

django.db.utils.OperationalError: could not translate host name "postgres.railway.internal" to address: nodename nor servname provided, or not known

2

Answers


  1. Chosen as BEST ANSWER

    The problem was the Host and Port. I found public host and port on Railway. Now it works.


  2. I faced the same problem, I solved by using public networking provided in the settings section of railway.app, when you click on the settings section you will see the public networking and below it is the host name and port number. Use that host name and change the port to that port number beside it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search