marsrover
marsrover

Reputation: 715

Heroku: PG::ConnectionBad: could not connect to server: No such file or directory

I´m having some trouble sharing a postgres database between my two Heroku apps.

I want the database of App A to be shared with App B, so I attached the App A postgres to App B, then I deleted App B´s original database.

However, trying to connect to from App B to the database results in this message:

PG::ConnectionBad: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

I have tried to restart the dynos and such but still no luck. Does anyone have any ideas on how to solve this?

Upvotes: 3

Views: 3926

Answers (1)

MZaragoza
MZaragoza

Reputation: 10111

All you have to do is set the DATABASE_URL config var for app_a and app_b to the same value. First, get the DATABASE_URL for your app_a:

$ heroku config | grep DATABASE_URL  --app app_name_a DATABASE_URL => postgres://xxxxxx:[email protected]/xxxx

Then, set the DATABASE_URL for app_b to this value:

$ heroku config:add DATABASE_URL=postgres://xxxxxx:[email protected]/xxxx --app app_name_b
Adding config vars: DATABASE_URL => postgres://xxxxxx:[email protected]/xxxx Restarting app... done, v99. 

That's it

I hope that this helps

Upvotes: 1

Related Questions