tobeannounced
tobeannounced

Reputation: 1999

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?

Upvotes: 21

Views: 6556

Answers (5)

andy
andy

Reputation: 8875

If you're using Rolify pre version 3.5 then it might be that:

https://github.com/EppO/rolify/issues/221

Upvotes: 0

Saqib R.
Saqib R.

Reputation: 3069

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"

Upvotes: 1

desheikh
desheikh

Reputation: 286

The heroku dev center talks about troubleshooting this. Basically your rails4 app should not rely on having config vars present during runtime.

https://devcenter.heroku.com/articles/rails-asset-pipeline#troubleshooting

Upvotes: 0

Hendrik
Hendrik

Reputation: 4929

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

Upvotes: 38

tobeannounced
tobeannounced

Reputation: 1999

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

Upvotes: 6

Related Questions