heroku Postgresql错误连接

heroku Postgresql错误连接,postgresql,heroku,Postgresql,Heroku,当我运行heroku run rials console时,会出现以下错误: /app/vendor/bundle/ruby/2.2.0/gems/pg-0.18.4/lib/pg.rb:45:in `初始化“:无法连接到服务器:没有这样的文件或目录 (PG::ConnectionBad)服务器是否在本地运行并接受 Unix域套接字上的连接 “/var/run/postgresql/.s.PGSQL.5432” 该应用程序在本地运行,运行于Puma和Postgresql,其设置与heroku相同

当我运行heroku run rials console时,会出现以下错误:

/app/vendor/bundle/ruby/2.2.0/gems/pg-0.18.4/lib/pg.rb:45:in `初始化“:无法连接到服务器:没有这样的文件或目录 (PG::ConnectionBad)服务器是否在本地运行并接受 Unix域套接字上的连接 “/var/run/postgresql/.s.PGSQL.5432”

该应用程序在本地运行,运行于Puma和Postgresql,其设置与heroku相同

以下是错误消息的其余部分:

from /app/vendor/bundle/ruby/2.2.0/gems/pg-0.18.4/lib/pg.rb:45:in `new'
from /app/vendor/bundle/ruby/2.2.0/gems/pg-0.18.4/lib/pg.rb:45:in `connect'
from /app/app/controllers/incomes-to-json.rb:5:in `<top (required)>'
from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:360:in `require_or_load'
from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:317:in `depend_on'
from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:233:in `require_dependency'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:472:in `block (2 levels) in eager_load!'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:471:in `each'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:471:in `block in eager_load!'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:469:in `each'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:469:in `eager_load!'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:346:in `eager_load!'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application/finisher.rb:56:in `each'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `instance_exec'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `run'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:55:in `block in run_initializers'
from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `each'
from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `call'
from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:54:in `run_initializers'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application.rb:352:in `initialize!'
from /app/config/environment.rb:5:in `<top (required)>'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application.rb:328:in `require'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application.rb:328:in `require_environment!'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:142:in `require_application_and_environment!'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:67:in `console'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
from /app/bin/rails:9:in `require'
from /app/bin/rails:9:in `<main>'
from/app/vendor/bundle/ruby/2.2.0/gems/pg-0.18.4/lib/pg.rb:45:in'new'
from/app/vendor/bundle/ruby/2.2.0/gems/pg-0.18.4/lib/pg.rb:45:in'connect'
从/app/app/controllers/incoments到json.rb:5:in`'
from/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active\u support/dependencies.rb:274:in'require'
from/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active\u support/dependencies.rb:274:in'block in require'
来自/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active\u support/dependencies.rb:240:in'load\u dependencity'
from/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active\u support/dependencies.rb:274:in'require'
来自/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active\u support/dependencies.rb:360:“需要或加载”中
来自/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active\u support/dependencies.rb:317:in'dependent\u'
来自/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active\u support/dependencies.rb:233:in“require\u dependencity”
from/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:472:in'block(2层)in eager_load!'
from/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:471:in'each'
from/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:471:in'block in eager_load!'
from/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:469:in'each'
来自/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:469:in'eager_load!'
from/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:346:in'eager_load!'
from/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application/finisher.rb:56:in'each'
from/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application/finisher.rb:56:in'block-in'
from/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in'instance_exec'
from/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in'run'
from/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:55:“运行中的块初始化器”
from/app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:226:in'block in tsort_each'
from/app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:348:in“每个强连接的组件中的块(2个级别)”中
from/app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:429:在'each_强力连接的组件'u from'中
from/app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:347:in“每个强连接的组件中的块”
from/app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:在'each'中
from/app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:in'call'
from/app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:“每个强连接的组件”
from/app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:224:in'tsort_each'
from/app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:203:in'tsort_each'
from/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:54:in'run_initializers'
来自/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application.rb:352:in'initialize!'
from/app/config/environment.rb:5:in`'
from/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application.rb:328:in'require'
来自/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application.rb:328:in'require_environment!'
来自/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands\u tasks.rb:142:in“require\u application\u and\u environment!”
from/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:67:in'console'
来自/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands\u tasks.rb:39:in'run\u command!'
来自/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in`'
from/app/bin/rails:9:in'require'
from/app/bin/rails:9:in`'

我已经安装了pg gem,创建了一个数据库,并在heroku上进行了迁移

您是否使用本地主机或IP地址获取连接详细信息?如果您使用的不是本地主机,则需要修改pg_hba.conf。不确定在哪里可以找到此pg_hba.conf文件。我刚刚在我的系统中搜索了/app/vendor/bundle/ruby/2.2.0/gems/pg-0.18.4/lib/pg.rb,它甚至不在我的文件中,可能在heroku服务器上吗?您是否使用本地主机或IP地址获取连接详细信息?如果您使用的不是本地主机,则需要修改pg_hba.conf。不确定在哪里可以找到此pg_hba.conf文件。我刚刚在我的系统中搜索了/app/vendor/bundle/ruby/2.2.0/gems/pg-0.18.4/lib/pg.rb,它甚至不在我的文件中,可能在heroku服务器上吗?