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?
Solved:
add
host: localhost
to the database.yml file
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.