django.db.utils.OperationalError: could not translate host name "postgres.railway.internal"

mcreations
TRIAL

a year ago

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 a changed the settings.py file to migrate to railway, using railway variables.

now i can't runserver, or migrate, and i get this error...

please help

Solved

22 Replies

a year ago

Is the Postgres database in the same project as the Django app?


mcreations
TRIAL

a year ago

Yes, the project was working...

here is my database settings

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

yayadrian
HOBBY

a year ago

Following this, as I'm also getting the same error.


a year ago

yayadrian, there is a multitude of common mistakes you can make to get this error, please open your own thread instead.


a year ago

mcreations, are you on the v2 runtime?


mcreations
TRIAL

a year ago

please excuse my ignorance, however i don't know what v2 runtime is...

i'm on a mac

running everything from the VScode terminal


a year ago

My question was in relation to your Railway service, not your own computer.

Check your service settings.


mcreations
TRIAL

a year ago

just checked it

it's v2


a year ago

Please attach a screenshot of your Railway project.


mcreations
TRIAL

a year ago

That's the thing...

i just started a new project, and did nothing...

so it's just a new project in railway, with nothing done to it...

i'll attach the screenshot anyway..


mcreations
TRIAL

a year ago

as i said.... i have nothing in my railway... so i got a screenshot of the project settings

Attachments


a year ago

Where is your Django service?


mcreations
TRIAL

a year ago

my django project is in my mac

local

i was going to start to up the project to railway

the first step was to create an account, get the variables from railway, then run "python3 manage.py migrate" command to migrate the database to railway and start the process in railway

i'm following the videos from codemy \ channel (ecommerce project)


mcreations
TRIAL

a year ago

my django project is in my mac

local

i was going to start to up the project to railway

the first step was to create an account, get the variables from railway, then run "python3 manage.py migrate" command to migrate the database to railway and start the process in railway

i'm following the videos from codemy \ channel (ecommerce project)


mcreations
TRIAL

a year ago

my django project is in my mac

local

i was going to start to up the project to railway

the first step was to create an account, get the variables from railway, then run "python3 manage.py migrate" command to migrate the database to railway and start the process in railway

i'm following the videos from codemy \ channel (ecommerce project)


a year ago

You can not connect to the private domain locally, it would not be very private if you could, you need to use the public host and port.


mcreations
TRIAL

a year ago

so instead of using the variable PGHOST i should use DATABASE_PUBLIC_URL as HOST in my setting.py file?


a year ago

A URL is not a Host, you need to use the public host and port.


mcreations
TRIAL

a year ago

again excuse my ignorance, but...

where do i get those variables? public host and port....

and thank you so much for your help


a year ago

In the service settings of the database service.


mcreations
TRIAL

a year ago

i'm using the trial from railway

i couldn't find any public host here

i ran more tests connecting, and got the same error, even from a new terminal, out of the project...


a year ago

You need to use the public host and port, open the database and then open its settings and you will see the public host and port.

Marking as solved since I am confident this is the issue and at this point I've just been repeating myself.


Status changed to Solved brody 12 months ago


django.db.utils.OperationalError: could not translate host name "postgres.railway.internal" - Railway Help Station