postgresql无法连接错误。
问题描述:
这是我的错误。postgresql无法连接错误。
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?
我使用自制软件到/ usr/local/bin目录/ PSQL 为了得到它认识到这个版本,我不得不加入到我的bash文件安装PostgreSQL的。
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
我得到的以上错误 任何人都可能知道为什么会发生这种情况。
答
正如消息所述,导致此错误的最可能原因是您实际上并未运行postgres服务器。通常你会引导这个了*的/ etc/init.d /的pg_ctl,*但既然你安装了这个通过酿造,只需在终端窗口
postgres
运行以下命令,服务器应启动。如果您没有将此设置在启动时自动启动,则每次重新启动计算机后都需要运行该命令。
postgres不知道在哪里可以找到服务器配置文件。 您必须指定--config-file或-D调用选项或设置PGDATA环境变量。 – user1096509 2013-03-06 00:16:00
好的发现如何使用命令行'brew info postgres'启动它。启动行是'pg_ctl -D/usr/local/var/postgres -l /usr/local/var/postgres/server.log start' – user1096509 2013-03-06 00:26:30
当我从mysql更改为postgres时,在Nitrous.io上发生此错误。不得不重新启动这个盒子,把我的database.yml改成'host:localhost'并把'listen address改为'*''。 我的最终解决方案发现[这里](https://serverfault.com/questions/461257/cant-connect-to-postgres-in-production/461265#461265) – Shadoath 2014-10-21 22:33:05