PG错误不知道如何调试

时间:2013-05-14 19:06:29

标签: ruby-on-rails postgresql

Exiting
/Users/judyngai/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record    /connection_adapters/postgresql_adapter.rb:1216:in `initialize': could not connect to          server: No such file or directory (PG::Error)
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

我阅读了一些帖子,有人建议添加

host:localhost

到database.yml文件

然后我收到了这个新错误

Exiting
/Users/judyngai/.rvm/gems/ruby-1.9.3-p392/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?

有人能指出我正确的方向吗?

我认为我没有提供足够的信息

当我做的时候

psql --version
psql (PostgreSQL) 9.2.4

which psql 
/usr/local/bin/psql

我的机器上安装了psql

这是我的database.yml文件

test:
  adapter: postgresql
  encoding: unicode
  database: pinny_test
  pool: 5
  username: judyngai
  password:
  host: localhost

development:
  adapter: postgresql
  encoding: unicode
  database: pinny_development
  pool: 5
  username: judyngai
  password:
  host: localhost

我取消了生产部分的注释。

2 个答案:

答案 0 :(得分:1)

您似乎错误配置了PostgreSQL。您需要更改pg_hba.conf中的配置。您可以看到此答案https://stackoverflow.com/a/7696398/1405852

答案 1 :(得分:0)

我假设您的database.yml文件看起来像这样:

development:
  adapter: postgresql
  database: app_development
  host: localhost

test:
  adapter: postgresql
  database: app_test
  host: localhost

production:
  adapter: postgresql
  database: app_production
  host: localhost

您需要安装并运行Postgres App。这是documentation

如果您仍有问题,请告诉我。