无法部署到Heroku,因为服务器拒绝连接

时间:2013-08-29 05:39:15

标签: ruby-on-rails postgresql heroku heroku-postgres

我想将本地Rails应用程序(完美地运行)部署到Heroku,但是收到以下错误消息:

rake aborted!
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
/tmp/build_21pkcz898c28o/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `initialize'

关于postgres_adapter

的许多行

我有点失望,因为我认为Heroku覆盖了 config / database.yml ,所以为什么会谈到在127.0.0.1上运行服务器(我不是在寻找远程服务器)分贝)?

谢谢,

更新

如果这有帮助,则运行heroku config会提供以下信息:

DATABASE_URL:               xxx
HEROKU_POSTGRESQL_GRAY_URL: xxx (the same xxx as above)

2 个答案:

答案 0 :(得分:11)

在您的application.rb中包含以下内容,位于Module Appname

上方
config.assets.initialize_on_precompile = false

阅读Heroku Labs: user-env-compile文章

答案 1 :(得分:0)

我使用的是Rails 4.0.4,上面没有一个能为我工作。

关注heroku documentation

RAILS_ENV=production bundle exec rake assets:precompile

然后

git add public/assets
git commit -m "vendor compiled assets"

部分解决了我...我可以推动heroku master'但是我的Bootstrap样式没有应用。

要解决这个最后的部分,我添加了推荐的' rails_12factor'宝石在我的宝石文件中。

group :production do
  gem 'thin'
  gem 'rails_12factor'
end

在我的git推送之后,所有工作都很好。