【问题标题】:PG::ConnectionBad when deploying to heroku [closed]部署到heroku时的PG :: ConnectionBad [关闭]
【发布时间】:2015-08-10 21:44:35
【问题描述】:

我有一个使用 sqlite3 创建的 ruby​​ 应用程序,现在想放在 heroku 上,所以我把它移到了 postgresql。当我运行工头启动它完美地工作。每当我在 heroku 中运行应用程序时,都会出现此错误:

编辑: 进行一些更改后,我的日志中出现了不同的错误。

2015-05-28T12:09:21.138869+00:00 heroku[web.1]: Starting process with command `ruby app.rb`
2015-05-28T12:09:21.526857+00:00 heroku[web.1]: Process exited with status 1
2015-05-28T12:09:24.240862+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize': could not translate host name "ec2-54-83-25-238.compute-1.amazonaws.com (PG::ConnectionBad)
2015-05-28T12:09:24.240881+00:00 app[web.1]: " to address: Name or service not known

编辑:错误消息引用我的 app.rb 文件的第 8 行结束。

app.rb:8 set :database, {adapter:"postgresql",port:"5432",database:"d9fnf2lrkap7tc",password:"_mH7ffuBYU8Wtqx36gxf80ZqFH",username:"axtoixdkvjyboe"}

数据库.yml:

development:
  adapter: postgresql
  encoding: utf8
  database: d9fnf2lrkap7tc
  username: axtoixdkvjyboe
  password: _mH7ffuBYU8Wtqx36gxf80ZqFH
  host: ec2-54-83-25-238.compute-1.amazonaws.com

【问题讨论】:

  • 需要您的config/database.yml 来调查问题。
  • 你的 gem 文件中有 pg gem 吗?
  • 是的,我的 Gemfile 中有 pg
  • 你能粘贴你的 database.yml 配置吗?
  • 你能检查一下你的database.yml中是否有这个设置作为主机:localhost

标签: ruby postgresql activerecord heroku sinatra


【解决方案1】:

我在我的项目中有一个额外的换行符解决了我的问题,但在经历过程中我了解到我不需要 database.yml,我可以将它设置为:在我的应用程序文件中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-07
    • 1970-01-01
    • 2019-04-17
    • 1970-01-01
    相关资源
    最近更新 更多