PG::ConnectionBad 部署到 heroku 时
PG::ConnectionBad when deploying to heroku
我有一个使用 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"}
Database.yml:
development:
adapter: postgresql
encoding: utf8
database: d9fnf2lrkap7tc
username: axtoixdkvjyboe
password: _mH7ffuBYU8Wtqx36gxf80ZqFH
host: ec2-54-83-25-238.compute-1.amazonaws.com
我的项目中有一个额外的换行符解决了我的问题,但在完成过程中我了解到我不需要 database.yml 并且我可以将它放在 set: 下在我的应用程序文件中
我有一个使用 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"}
Database.yml:
development:
adapter: postgresql
encoding: utf8
database: d9fnf2lrkap7tc
username: axtoixdkvjyboe
password: _mH7ffuBYU8Wtqx36gxf80ZqFH
host: ec2-54-83-25-238.compute-1.amazonaws.com
我的项目中有一个额外的换行符解决了我的问题,但在完成过程中我了解到我不需要 database.yml 并且我可以将它放在 set: 下在我的应用程序文件中