2014-01-17 175 views
1

我拼命地試圖推送我的應用程序到heroku,但它失敗並顯示此錯誤消息。 它適用於我的本地機器,但我甚至無法將它推送到heroku。 我一直在努力使這項工作幾天,但無法找到。Heroku:Postgres - 無法連接到服務器:連接被拒絕

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? 

    Running: rake assets:precompile 
    Running: rake assets:precompile 
    Connecting to database specified by DATABASE_URL 
    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_6c1232cd-5bee-4760-a11c-1745627fba6e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `initialize' 
    /tmp/build_6c1232cd-5bee-4760-a11c-1745627fba6e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `new' 
    /tmp/build_6c1232cd-5bee-4760-a11c-1745627fba6e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `connect' 
    .... 
    /tmp/build_6c1232cd-5bee-4760-a11c-1745627fba6e/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:93:in `block (2 levels) in <top (required)>' 
    /tmp/build_6c1232cd-5bee-4760-a11c-1745627fba6e/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>' 
    /tmp/build_6c1232cd-5bee-4760-a11c-1745627fba6e/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:23:in `invoke_or_reboot_rake_task' 
    /tmp/build_6c1232cd-5bee-4760-a11c-1745627fba6e/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>' 
    Tasks: TOP => environment 
    (See full trace by running task with --trace) 
! 
!  Precompiling assets failed. 
! 

!  Push rejected, failed to compile Ruby app 

這裏是我的Gemfile

源 'http://rubygems.org' 紅寶石 '2.0.0'

gem 'rails', '3.2.14' 
    gem 'json' 
    gem 'thin' 
    gem 'rails_12factor' 
    gem 'paymill' 
    gem 'pg', "0.16.0" 
    gem 'haml' 
    gem 'jammit', :git => 'https://github.com/documentcloud/jammit.git', :branch => 'master' 
    gem 'sass-rails' 
    gem 'uglifier' 
    gem 'aws-s3' 
    gem 'aws-sdk' 
    gem 'friendly_id' 
    gem 'devise', '~> 2.2.7' 
    gem 'activeadmin', "0.6.0" 
    gem 'formtastic' 
    gem 'inherited_resources' 
    gem 'paperclip', '~> 2.4' 
    gem 'country_select' 
    gem 'coffee-script' 

    group :development, :test do 
    gem 'escape_utils' 
    gem 'rails-footnotes' 
    gem 'rack-webconsole' 
    gem 'better_errors' 
    gem 'binding_of_caller' 
    gem 'pry' 
    gem 'pry-debugger' 
    end 

    group :test do 
    gem 'factory_girl_rails', '~> 4.1.0' 
    gem 'rspec-rails', '~> 2.14.0' 
    gem 'cucumber-rails', '~> 1.4.0', require: false 
    gem 'database_cleaner', '~> 1.0.1' 
    # gem 'capybara', '~> 2.1.0' 
    gem 'simplecov', require: false 
    end 
+0

您是否嘗試過創建一個新的Heroku應用程序,看它是否推到那裏工作? –

+0

在生產你的database.yml你有heroku數據庫設置? –

+1

@SamD Heroku覆蓋數據庫配置,因此不需要在該文件中進行設置。 –

回答

0

你可以修改你的Gemfile?

group :development, :test do 
    gem 'sqlite3' 
end 

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

所以基本上添加這些3顆寶石。 然後執行「捆綁安裝」,然後將其推送到Heroku。 希望這個作品。

0

請嘗試以下

$ heroku labs:enable user-env-compile 

的問題可能是由寶石之一造成正試圖在資產預編譯連接到數據庫。查看Heroku Labs: user-env-compile的heroku文檔,看看它是如何工作的。

2

好吧,我剛剛在我的應用程序中解決了這個塊。

訣竅是故障排除文檔https://devcenter.heroku.com/articles/rails-asset-pipeline#troubleshooting在:

資產失敗最常見的原因:預編譯的是,依賴於擁有目前啓動其環境的應用程序。您的應用程序的配置變量在slug編譯期間並不存在於環境中,因此您應該採取措施來處理初始化程序中配置變量(和附加資源)的零情況。

在Rails 3.x中,可以防止初始化應用程序,並通過確保下面一行在你的config/application.rb中連接到數據庫:

config.assets.initialize_on_precompile = false

不要忘了在更改此設置後提交git。

還有就是這更說明在回答這個胎面:Error pushing to heroku - aborting my rake assets:precompile

相關問題