【问题标题】:Rails 4 + Postgres: Randomly cannot connect to development serverRails 4 + Postgres:随机无法连接到开发服务器
【发布时间】:2016-10-13 13:19:31
【问题描述】:

我正在运行 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?

有人见过吗?

【问题讨论】:

  • 重启你的 postgres 服务器:sudo service postgresql restart
  • 上面写着sudo: service: command not found

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


【解决方案1】:

Neara 对这篇文章的回复为我提供了答案:PostgreSQL server won't stop

基本上不得不跑:

$ brew services list
$ brew services restart postgresql

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

【讨论】:

    猜你喜欢
    • 2012-11-04
    • 1970-01-01
    • 2013-11-15
    • 2013-04-14
    • 2017-03-24
    • 2015-06-20
    • 2018-03-09
    • 1970-01-01
    相关资源
    最近更新 更多