【问题标题】:PG:ConnectBad Rails 4 PostgresqlPG:ConnectBad Rails 4 Postgresql
【发布时间】:2013-11-05 15:27:29
【问题描述】:

我知道这个问题似乎已经被问过一百次了,但这次我觉得不同了。

当我重新启动我的 mac 并运行 rails 时,该站点运行正常。

➜  BankingApp git:(master) ✗ which psql
/Applications/Postgres.app/Contents/MacOS/bin/psql
➜  BankingApp git:(master) ✗ which postgres
/Applications/Postgres.app/Contents/MacOS/bin/postgres

但是当我重新启动服务器时,它每次都会出现这个错误。

我正在使用 osx 山狮和 Postgres.app。我也在使用使用 .zshrc 的 omyzsh。在那个文件中我有:

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
export PGHOST=localhost

我还运行了 Postgres.app。

数据库.yml

development:
  adapter: postgresql
  database: BankingApp
  pool: 5
  timeout: 5000

如果我使用 PGAdmin 3 打开数据库,我可以从表等中进行选择。它似乎正在工作。我认为一定有一个流氓进程给出了这个错误。

could not connect to server: No such file or directory Is the server running locally and                 accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

Rails.root: /Users/jod/BankingApp

追踪:

activerecord (4.0.0.rc1) lib/active_record/connection_adapters/postgresql_adapter.rb:796:in `initialize'
activerecord (4.0.0.rc1) lib/active_record/connection_adapters/postgresql_adapter.rb:796:in `new'
activerecord (4.0.0.rc1) lib/active_record/connection_adapters/postgresql_adapter.rb:796:in `connect'
activerecord (4.0.0.rc1) lib/active_record/connection_adapters/postgresql_adapter.rb:513:in `initialize'
activerecord (4.0.0.rc1) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
activerecord (4.0.0.rc1) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
activerecord (4.0.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection'
activerecord (4.0.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_connection'
activerecord (4.0.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connection'
activerecord (4.0.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `block in checkout'
/Users/jod/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
activerecord (4.0.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
activerecord (4.0.0.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'

【问题讨论】:

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


    【解决方案1】:
    development:
      adapter: postgresql
      database: BankingApp
      pool: 5
      timeout: 5000
      host: localhost
    

    这解决了问题!

    【讨论】:

      猜你喜欢
      • 2014-02-04
      • 2015-02-27
      • 2016-08-30
      • 1970-01-01
      • 2015-11-30
      • 1970-01-01
      • 2015-05-26
      • 2014-08-31
      • 2016-09-03
      相关资源
      最近更新 更多