Rails 4 + Postgres:随机无法连接到开发服务器

时间:2016-10-13 13:19:31

标签: ruby-on-rails postgresql ruby-on-rails-4

我正在运行Rails 4.2.2并且我的postgres gem是0.17.1并且昨天一切运行正常但是今天当我打开控制台并尝试连接到数据库时我看到了这个错误:

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

...然后当我尝试通过运行psql连接到数据库时,我看到以下内容:

dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib
  Referenced from: /usr/local/bin/psql
  Reason: image not found
Abort trap: 6

据我所知,自昨天以来我没有改变任何事情,所以我不确定为什么会这样。我尝试将host: localhost添加到我的database.yml,但没有运气。当我尝试使用像PSequel这样的程序连接数据库时,可能值得注意,我看到以下内容:

could not connect to server: Connection refused
    is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

有没有人见过这个?

1 个答案:

答案 0 :(得分:0)

Neara对此帖的回复为我提供了答案:PostgreSQL server won't stop

基本上必须运行:

$ brew services list
$ brew services restart postgresql

他们发布了一个解决方法,以防无法找到services