Issue running rake or seeds file from Rails to connected Postgres

6 months ago

I am logged in using CLI and can see my Postgres with the tables as well as all my variables directly through the terminal but if I try to run a rake file or a seed file I get a connection error. I have tried what feels like a ton of different ways with no luck. I am at a complete loss at this point.

railway run rails db:seed

bin/rails aborted!

ActiveRecord::ConnectionNotEstablished: connection to server at "143.244.220.150", port 5432 failed: Operation timed out (ActiveRecord::ConnectionNotEstablished)

Is the server running on that host and accepting TCP/IP connections?

Caused by:

PG::ConnectionBad: connection to server at "143.244.220.150", port 5432 failed: Operation timed out (PG::ConnectionBad)

Is the server running on that host and accepting TCP/IP connections?

Tasks: TOP => db:abort_if_pending_migrations

(See full trace by running task with --trace)

Solved

4 Replies

6 months ago

Hello,

When running commands locally you need to use the public host and port of the database.


Status changed to Awaiting User Response railway[bot] 6 months ago


6 months ago

I could not get it to work so I just created a sql file and ran it through that. For future reference is there a way for me to run these kinds of 1 time files within your system instead of locally?


Status changed to Awaiting Railway Response railway[bot] 6 months ago


6 months ago

We don't have any mechanism to do that, commands that interact with the database would need to be ran locally.


Status changed to Awaiting User Response railway[bot] 6 months ago


6 months ago

It would be great if you had better documentation then on how to run these kind of commands. I spent over 4 hours trouble shooting only to decide to go a different approach. I went with the documentation on moving from Heroku to Railway using Postgres and my local db.


Status changed to Awaiting Railway Response railway[bot] 6 months ago


Status changed to Solved brody 6 months ago