Can't deploy to Heroku because the server refused the connection

heroku, heroku-postgres, postgresql, ruby-on-rails

Solution

Include the following in your application.rb, above the Module Appname

config.assets.initialize_on_precompile = false

And read the Heroku Labs: user-env-compile Article

Problem

I wanted to deploy my local Rails app (that works perfectly) to Heroku, but get the following error message: ``` 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_21pkcz898c28o/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `initialize' ``` Followed by many lines about `postgres_adapter`. I'm a bit disappointed because I red that Heroku overwrite config/database.yml so why does it talk about running the server on `127.0.0.1` (I'm not looking for remote db)? Thanks, Update If this can help, running `heroku config` gives the following: ``` DATABASE_URL: xxx HEROKU_POSTGRESQL_GRAY_URL: xxx (the same xxx as above) ```

Original source