Heroku:PG :: ConnectionBad:无法连接到服务器:连接被拒绝

时间:2015-09-28 04:31:01

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

我尝试将新应用推送到heroku并出现此错误PG::ConnectionBad: could not connect to server: Connection refused

这是我的gemfile,它与它有关吗?我正在使用邮政狂欢。我不确定,因为这是我第一次尝试在heroku中使用狂欢,但它似乎没有经历过。任何帮助将不胜感激

source 'https://rubygems.org'

ruby "2.2.1"

gem 'puma', '~> 2.13.4'
gem 'braintree', '~> 2.48.1'
gem 'rails', '4.2.3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

group :development, :test do
  gem 'byebug'
  gem 'web-console', '~> 2.0'
  gem 'spring'
end

    group :production, :staging do
        gem 'pg'
        gem 'rails_12factor', '~> 0.0.3'
    end


gem 'spree', '3.0.4'
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '3-0-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'

的database.yml

default: &default
  adapter: postgresql
  encoding: unicode
  pool: 5

development:
  <<: *default
  host: localhost
  database: ****
  username: **** 
  password: ****

test:
  <<: *default
  host: localhost
  database: ****
  username: **** 
  password: ****

production:
  <<: *default
  database: ****
  username: ****
  password: <%= ENV['DATABASE_PASSWORD'] %>

1 个答案:

答案 0 :(得分:10)

application.rb文件中,尝试设置:

config.assets.initialize_on_precompile = false

并查看是否可以解决您的问题。

此外,如果您尚未为应用预先设置数据库,则需要创建一个:

heroku addons:create heroku-postgresql

您可以运行以下命令验证数据库是否已添加到您的应用程序中:

heroku config --app your_app_name