0

这是我的错误。

PG::Error - could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
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?
could not connect to server: Connection refused
    Is the server running on host "localhost" (fe80::1) and accepting
    TCP/IP connections on port 5432?

我使用自制软件将 postgresql 安装到 /usr/local/bin/psql 为了让它识别这个版本,我必须将它添加到我的 bash 文件中。

export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"

当我 cd 进入我的 rails 应用程序并运行命令时

rails s

它从以下内容开始

=> Booting Thin
=> Rails 4.0.0.beta1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
>> Thin web server (v1.5.0 codename Knife)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop

然后,当我尝试查看应用程序时,http://0.0.0.0:3000我收到上述错误,任何人都可能知道为什么会发生这种情况。

4

1 回答 1

0

正如消息所述,此错误的最可能原因是您实际上并未运行 postgres 服务器。通常你会用 */etc/init.d/pg_ctl,* 来启动它,但是因为你是通过 brew 安装的,所以只需在终端窗口中运行以下命令

postgres

服务器应该启动。如果您没有将此设置为在启动时自动启动,则每次重新启动计算机后都需要运行该命令。

于 2013-03-06T00:00:14.687 回答