Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku Rails 4 could not connect to server: connection refused

Using postgres.
Haven't been able to push.

Tried this without any luck:

config.assets.initialize_on_precompile = false

-----> Preparing app for Rails asset pipeline

   Running: rake assets:precompile
   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?
like image 649
tobeannounced Avatar asked Apr 20 '13 19:04

tobeannounced


3 Answers

The accepted answer did not fully resolve this. I tried to find a solution for 2-3 hours without success, then this worked:

In your app directory.

heroku labs:enable user-env-compile

it is still failing?

heroku labs:disable user-env-compile
heroku labs:enable user-env-compile

Then it worked for me, just had to remove and do again.

The following config is no longer needed in Rails 4. Compiling assets must work without it.

config.assets.initialize_on_precompile = false
like image 164
Hendrik Avatar answered Nov 07 '22 07:11

Hendrik


config.assets.initialize_on_precompile = false

Include that in application.rb, ABOVE module APPNAME

I had originally included it inside

class Application < Rails::Application

Edit: actually, the above didn't fix it.

I had to do this

https://devcenter.heroku.com/articles/labs-user-env-compile

like image 35
tobeannounced Avatar answered Nov 07 '22 08:11

tobeannounced


Try executing locally

bundle exec rake assets:precompile RAILS_ENV=production

It might be because of devise gem as in my case. You might be missing secret key in devise initializer. try adding

config.secret_key = "PROVIDE-KEY"
like image 1
Saqib R. Avatar answered Nov 07 '22 08:11

Saqib R.