我知道已经讨论过这个主题,但没有一个答案对我有帮助。对不起,开始了一个新的话题……感谢任何提供帮助的人。
我每天都在本地机器上进行开发……这不是新设置,但服务器突然无法连接……不知道为什么。
我最初安装的 postgres 是通过 homebrew 安装的。我正在使用 pg gem 版本 0.15.1、ruby 2.0、rails 3.2.13、postgres 9.2.4。
$bundle exec rails s
=> Booting Thin
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/Hank/.rvm/gems/ruby-2.0.0-p0@rails329/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `initialize': could not connect to server: Connection refused (PG::Error)
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?
$brew 信息 postgres
postgresql: stable 9.2.4
通常当我遇到任何服务器错误时,我可以强制停止或重新启动,然后重新启动我的机器,一切都很好。这一次,我尝试了一系列 pg_ctl 命令,重新启动,重建权限并运行磁盘实用程序,gem pristine pg,卸载 pg,重新安装 pg,brew update postgres,会删除 .pid 文件,但当前没有创建。
$哪个postgres
/usr/local/bin/postgres
$哪个 psql
/usr/local/bin/psql
$ps 辅助 | grep postgres
returns: 1976 0.0 0.0 2430992 1584 s000 R+ 8:54PM 0:00.01 grep postgres