8 months ago
1. I want to add and modify objects in my database via rails console. I am using private dns(*.railway.internal) of database in config to my app.
When i run 'railway run rails console', it is not able to run command and fails with connection to database.
2. When i try to run railway run rake db:migrate it is not able to connect to the database and gives and error
PG::ConnectionBad: could not translate host name "myhost.railway.internal"
3 Replies
7 months ago
Doesn't seem to work with private, but it works with public.
I got it by running
railway shell
to load all your production variables
export DATABASE_URL='your_public_database_url_here'
to replace your private url with your public one
bin/rails console
Then you'll need to exit
once to get out of the console, and then exit
a 2nd time to get out of the Railway shell.
7 months ago
thanks
7 months ago
You dont have to do railway shell first. This also worksDATABASE_URL="your public url" railway run rails console