Could not translate hostname postgres.railway.internal

con607HOBBY

7 months ago

Hi, Im getting this error when connecting the postgres database from a rails api server, both on the same project.

`connect_start': could not translate host name "postgres.railway.internal" to address: nodename nor servname provided, or not known (PG::ConnectionBad)

I am using shared variables for the user, pass, db, and db url.

I tried looking for that legacy/v2 runtime option but i didnt find it in the service settings.
I also tried to connect to the DB remotely but it doesnt seem to respond.

project id: fa2241e1-ff5a-43d5-a6a3-2bee127d9156

0 Replies

con607HOBBY

7 months ago

fa2241e1-ff5a-43d5-a6a3-2bee127d9156


7 months ago

do you happen to be pro?
how long ago was the service created?
when you first deploy it, do you see any container event logs in the deploy logs?


con607HOBBY

7 months ago

No, just Hobby plan, the service was created about 2 months ago, it shows logs for the deploy only, at the end it says "database system is ready to accept connections"


7 months ago

ah should have been more clear, I am inquiring about the logs your app's deployment prints, not the databases


con607HOBBY

7 months ago

oh ok, I dont see any connection errors to the database on the app logs, but when i try to connect to the database or when i connect to the "rails console using railway run rails c -e production" command to try to connect from there, it does show me the error:

`connect_start': could not translate host name "postgres.railway.internal" to address: nodename nor servname provided, or not known (PG::ConnectionBad)


7 months ago

so you aren't getting this error when on railway?


con607HOBBY

7 months ago

I am getting the error when Im on railway. I just double checked the logs for the app, I pushed a change yesterday that had to run some migrations on the database, and the logs show it did run them successfully.

So I guess I am just not connecting to the database the right way from the terminal… To connect to the database using railway all i have to do is run "railway link" choose the postgres service and perform a normal psql command right?


7 months ago

please know that railway run runs the commands locally, and thus does not have access to the private network


con607HOBBY

7 months ago

I see


con607HOBBY

7 months ago

Thanks for the help


7 months ago

but did you also say you are getting the same errors from an app when deployed to railway?


con607HOBBY

7 months ago

On the app I dont see any errors but, I saw the error when connecting to the console that Rails framework provides, but to start the console I was using the "railway run" command, so I assume that console cannot access the database because it cannot resolve the private network hosts.


7 months ago

yep you can't access the private network locally


Could not translate hostname postgres.railway.internal - Railway Help Station