【问题标题】:Heroku: PG::ConnectionBad: could not connect to server: Connection refusedHeroku:PG :: ConnectionBad:无法连接到服务器:连接被拒绝
【发布时间】:2015-12-25 06:21:43
【问题描述】:

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

这是我的gemfile,和那个有关系吗?我正在使用 postgress 的狂欢。我不确定,因为这是我第一次尝试在 heroku 中使用 spree,但它似乎没有通过。任何帮助将不胜感激

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'

数据库.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'] %>

【问题讨论】:

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


    【解决方案1】:

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

    config.assets.initialize_on_precompile = false
    

    看看这是否能解决您的问题。

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

    heroku addons:create heroku-postgresql
    

    您可以通过运行来验证数据库是否已添加到您的应用程序中:

    heroku config --app your_app_name
    

    【讨论】:

    • 你可以试试这个吗? heroku addons:create heroku-postgresql
    • 我收到了TypeError: no implicit conversion of String into Integer
    • 这似乎是一个新错误,而且很可能不是 Heroku 特定的,而是您的应用程序特定的。先看看你的应用在本地是否正常运行。
    • 感谢我的情况,因为我在没有先添加 heroku-postgresql 的情况下点击了“升级到生产”
    猜你喜欢
    • 2013-11-18
    • 2015-01-31
    • 2013-11-15
    • 1970-01-01
    • 2018-09-24
    • 1970-01-01
    • 1970-01-01
    • 2020-12-09
    相关资源
    最近更新 更多