[英]Rails cannot find my Postgres server on Mac OS X / PG::ConnectionBad: could not connect to server
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). 我正在遵循Rails教程,并尝试进行简单的迁移,但是我的Rails应用程序在查找我的Postgres服务器时遇到了麻烦(我使用的是Mac OS X)。
When I run bundle exec rake db:migrate
on my rails app, I get the following error 当我在Rails应用程序上运行bundle exec rake db:migrate
时,出现以下错误
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 当我输入sudo lsof -i tcp:5432
我得到了输出
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. 因此,Postgres显然在端口5432上运行。
What could be the solution? 有什么解决方案?
Solved: 解决了:
add 加
host: localhost
to the database.yml file 到database.yml文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.