Home Rails cannot find my Postgres server on Mac OS X / PG::ConnectionBad: could not connect to server
Reply: 1

Rails cannot find my Postgres server on Mac OS X / PG::ConnectionBad: could not connect to server

Kevin L.
1#
Kevin L. Published in 2018-02-14 01:54:53Z

I am following a rails tutorial and am trying to do a simple migration but my rails app is having trouble finding my Postgres server (I'm using mac OS X).

When I run bundle exec rake db:migrate on my rails app, I get the following error

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/pgsql_socket/.s.PGSQL.5432"?

When I type sudo lsof -i tcp:5432 I get the output

COMMAND  PID     USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
postgres  73 postgres    4u  IPv6 0xd0338068e4dc128d      0t0  TCP *:postgresql (LISTEN)
postgres  73 postgres    5u  IPv4 0xd0338068e4852e55      0t0  TCP *:postgresql (LISTEN)

So Postgres is clearly running on port 5432.

What could be the solution?

Kevin L.
2#
Kevin L. Reply to 2018-02-14 03:42:53Z

Solved:

add

host: localhost 

to the database.yml file

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.298812 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO