问题描述
我尝试将新应用推送到heroku并出现此错误 PG :: ConnectionBad:无法连接到服务器:连接被拒绝
I tried pushing new app to heroku and go this error PG::ConnectionBad: could not connect to server: Connection refused
这是我的gemfile,与它有关吗?我正在疯狂使用postgress。我不确定,因为这是我第一次尝试在Heroku中使用Spree,但似乎没有成功。
This is my gemfile, does it have to do with that? I'm using spree with postgress. I'm not sure since this is the first time I've tried using spree in heroku but it doesn't seem to be going through. Any help would be appreciated
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
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'] %>
推荐答案
在您的 application.rb中
文件,尝试设置以下内容:
In your application.rb
file, try setting this:
config.assets.initialize_on_precompile = false
,看看是否能解决您的问题。
and see if that fixes your issue.
此外,如果您尚未为您的应用程序预先配置数据库,您需要创建一个数据库:
Also, if you already did not pre-provision the database for your app, you need to create one:
heroku addons:create heroku-postgresql
您可以通过运行以下命令来验证数据库已添加到应用程序中:
You can verify the database was added to your application by running:
heroku config --app your_app_name
这篇关于Heroku:PG :: ConnectionBad:无法连接到服务器:连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!