PG :: ConnectionBad - 无法连接到服务器:连接被拒绝

PG :: ConnectionBad - 无法连接到服务器:连接被拒绝

每次我运行rails 4.0服务器时,我都会得到这个输出。


Started GET "/" for 127.0.0.1 at 2013-11-06 23:56:36 -0500


PG::ConnectionBad - 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?

:

 activerecord (4.0.0) lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `connect'

 activerecord (4.0.0) lib/active_record/connection_adapters/postgresql_adapter.rb:542:in `initialize'

 activerecord (4.0.0) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'

 activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection'

我正在运行Mavericks OS X 10.9所以我不知道这是不是问题。我已尽力而为,但似乎没有任何工作。我已经多次卸载并安装了postgres和pg gem。


这是我的database.yml文件


development:

  adapter: postgresql

  encoding: unicode

  database: metals-directory_development

  pool: 5

  username: 

  password: 

  template: template0

  host: localhost

  port: 5432


test: &test

  adapter: postgresql

  encoding: unicode

  database: metals-directory_test

  pool: 5

  username: 

  password: 

  template: template0

  host: localhost

  port: 5432


staging:

  adapter: postgresql

  encoding: unicode

  database: metals-directory_production

  pool: 5

  username:

  password:

  template: template0

  host: localhost


production:

  adapter: postgresql

  encoding: unicode

  database: metals-directory_production

  pool: 5

  username:

  password:

  template: template0

  host: localhost


cucumber:

  <<: *test


茅侃侃
浏览 1309回答 3
3回答

一只名叫tom的猫

我已经设法通过遵循Chris Slade的答案来解决问题,但是要重新启动服务器,我必须使用以下命令:launchctl&nbsp;unload&nbsp;~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist launchctl&nbsp;load&nbsp;~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Ruby