为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

茅侃侃 2019-08-29 08:35:01
PG :: ConnectionBad - 无法连接到服务器:连接被拒绝每次我运行rails 4.0服务器时,我都会得到这个输出。Started GET "/" for 127.0.0.1 at 2013-11-06 23:56:36 -0500PG::ConnectionBad - could not connect to server: Connection refusedIs the server running on host "localhost" (::1) and acceptingTCP/IP connections on port 5432?could not connect to server: Connection refusedIs the server running on host "localhost" (127.0.0.1) and acceptingTCP/IP connections on port 5432?could not connect to server: Connection refusedIs the server running on host "localhost" (fe80::1) and acceptingTCP/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: 5432test: &test  adapter: postgresql  encoding: unicode  database: metals-directory_test  pool: 5  username:   password:   template: template0  host: localhost  port: 5432staging:  adapter: postgresql  encoding: unicode  database: metals-directory_production  pool: 5  username:  password:  template: template0  host: localhostproduction:  adapter: postgresql  encoding: unicode  database: metals-directory_production  pool: 5  username:  password:  template: template0  host: localhostcucumber:  <<: *test
查看完整描述

3 回答

?
一只名叫tom的猫

TA贡献1906条经验 获得超2个赞

我已经设法通过遵循Chris Slade的答案来解决问题,但是要重新启动服务器,我必须使用以下命令:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist


查看完整回答
反对 回复 2019-08-29
  • 3 回答
  • 0 关注
  • 1153 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信