简体   繁体   English

Rails在Mac OS X / PG :: ConnectionBad上找不到我的Postgres服务器:无法连接到服务器

[英]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.

相关问题 PG::ConnectionBad - 无法连接到服务器:Mac OS X 上的连接被拒绝 - PG::ConnectionBad - could not connect to server: Connection refused on Mac OS X Rails-Postgres-无法连接到服务器:连接被拒绝(PG :: ConnectionBad) - Rails - Postgres - could not connect to server: Connection refused (PG::ConnectionBad) PG :: ConnectionBad,无法连接到服务器 - PG::ConnectionBad, could not connect to server PG ConnectionBad 无法连接到服务器 - PG ConnectionBad Could not connect to server PG::ConnectionBad 无法连接到服务器 - heroku 本地 rails 应用程序 - PG::ConnectionBad could not connect to server - heroku local rails app PG::ConnectionBad - 无法连接到服务器:连接被拒绝 - PG::ConnectionBad - could not connect to server: Connection refused PG :: ConnectionBad:无法连接到服务器(heroku) - PG::ConnectionBad: could not connect to server (heroku) PG :: ConnectionBad:无法连接到服务器:连接被拒绝 - PG::ConnectionBad: could not connect to server: Connection refused 无法连接到服务器:没有这样的文件或目录(PG::ConnectionBad) - could not connect to server: No such file or directory (PG::ConnectionBad) Rails db:create using PostgreSQL return PG::ConnectionBad: 无法连接到服务器:连接被拒绝 - Rails db:create using PostgreSQL return PG::ConnectionBad: could not connect to server: Connection refused
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM