ruby-on-rails - 名称解析暂时失败 (PG::ConnectionBad)

标签 ruby-on-rails heroku heroku-toolbelt heroku-postgres

我在 Heroku EU 托管了 Rails 4 应用程序。

这两天我几乎无法启动 Heroku 控制台。 100 次尝试中有 90 次以如下错误结束:

scaryguy@ubuntu:~/Sites/xxxxx.com$ heroku run console
Running `console` attached to terminal... up, run.9208
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `initialize': could not translate host name "ec2-54-221-224-138.compute-1.amazonaws.com" to address: Temporary failure in name resolution (PG::ConnectionBad)
    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `new'
    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `connect'
    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:542:in `initialize'
    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection'
    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_connection'
    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connection'
    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `block in checkout'
    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection'
    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_handling.rb:79:in `retrieve_connection'
    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_handling.rb:53:in `connection'
    from /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/model_schema.rb:203:in `table_exists?'
    from /app/vendor/bundle/ruby/2.0.0/gems/acts-as-taggable-on-2.4.1/lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb:5:in `included'
    from /app/vendor/bundle/ruby/2.0.0/gems/acts-as-taggable-on-2.4.1/lib/acts_as_taggable_on/taggable.rb:98:in `include'
    from /app/vendor/bundle/ruby/2.0.0/gems/acts-as-taggable-on-2.4.1/lib/acts_as_taggable_on/taggable.rb:98:in `taggable_on'
    from /app/vendor/bundle/ruby/2.0.0/gems/acts-as-taggable-on-2.4.1/lib/acts_as_taggable_on/taggable.rb:39:in `acts_as_taggable_on'
    from /app/vendor/bundle/ruby/2.0.0/gems/acts-as-taggable-on-2.4.1/lib/acts_as_taggable_on/taggable.rb:15:in `acts_as_taggable'
    from /app/app/models/article.rb:6:in `<class:Article>'
    from /app/app/models/article.rb:1:in `<top (required)>'
    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:329:in `require_or_load'
    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:288:in `depend_on'
    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:206:in `require_dependency'
    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:464:in `each'
    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:464:in `block in eager_load!'
    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:462:in `each'
    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:462:in `eager_load!'
    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:347:in `eager_load!'
    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `each'
    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each'
    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
    from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /app/config/environment.rb:5:in `<top (required)>'
    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
    from /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
    from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:63:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

我想知道这是否取决于我?或者这是一个广泛的错误,Heroku 不认为再次在他们的状态页面上发出通知。我不确定,因为我在使用新安装的 Ubuntu 时遇到了困难。一些 CA 购物车问题...但我现在可以连接到任何地方...好吧,我不确定。

我昨天在 Heroku 开了一张票,7 小时后他们的回答是“问题仍然存在吗?”。

最佳答案

在我更改虚拟机和物理操作系统的 DNS 设置以使用 Google DNS 后,一切都修复了!!!!!!

全部都是 DNS 问题...

我不知道谁该对这种情况负责?是我的 ISP 提供商吗?我该生谁的气??

这是常规的 Google DNS 设置:

8.8.8.8
8.8.4.4

关于ruby-on-rails - 名称解析暂时失败 (PG::ConnectionBad),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18890392/

相关文章:

ruby-on-rails - Ruby on rails + aws cognito 示例

python - 如何解决 Heroku 中的 "Push rejected, no Cedar-supported app detected"错误

heroku - Cloud9 IDE Heroku 登录

ruby-on-rails - rails 3 : Generate unique codes (coupons)

swift - 如何在 Heroku 上使用 swift 安全地处理 Slack 的 API token ?

java - 带有 Java ECONNREFUSED 的 Heroku Websockets(连接被拒绝)

Heroku 推送拒绝,未检测到 Cedar 支持的应用程序

ruby-on-rails - 如何在使用代理服务器访问互联网的 Windows 计算机上安装 Rails?

ruby-on-rails - 带有命名产量的 rails 部分布局 - 为什么从未使用过产量 block ?

ruby-on-rails - 多个 before_filter 语句用于正确的用户和管理员