How can i access rails console of prod app from my laptop

vipulsharma21HOBBY

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"

Solved

3 Replies

mehdig44HOBBY

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.


vipulsharma21HOBBY

7 months ago

thanks


vipulsharma21HOBBY

7 months ago

You dont have to do railway shell first. This also works
DATABASE_URL="your public url" railway run rails console


How can i access rails console of prod app from my laptop - Railway Help Station