部署到heroku时PG :: ConnectionBad

时间:2015-05-28 11:42:26

标签: ruby postgresql activerecord heroku sinatra

我有一个使用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

1 个答案:

答案 0 :(得分:0)

我的项目中有一个额外的换行符解决了我的问题,但是经历了我知道我不需要一个database.yml而且我可以把它放在set下:在我的app文件中

相关问题