R
Railway2mo ago
Con

Could not translate hostname postgres.railway.internal

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
13 Replies
Percy
Percy2mo ago
Project ID: fa2241e1-ff5a-43d5-a6a3-2bee127d9156
Con
ConOP2mo ago
fa2241e1-ff5a-43d5-a6a3-2bee127d9156
Brody
Brody2mo 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?
Con
ConOP2mo 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"
Brody
Brody2mo ago
ah should have been more clear, I am inquiring about the logs your app's deployment prints, not the databases
Con
ConOP2mo 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)
Brody
Brody2mo ago
so you aren't getting this error when on railway?
Con
ConOP2mo 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?
Brody
Brody2mo ago
please know that railway run runs the commands locally, and thus does not have access to the private network
Con
ConOP2mo ago
I see Thanks for the help
Brody
Brody2mo ago
but did you also say you are getting the same errors from an app when deployed to railway?
Con
ConOP2mo 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.
Brody
Brody2mo ago
yep you can't access the private network locally
Want results from more Discord servers?
Add your server