13

I'm pushing changes to Heroku and I get ...

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?

When I consult the Heroku documentation Here, it tells me I need to "configure a nonexistent database in your local config/database.yml" I'm not sure how to create a "nonexistent database"? I'm a beginner and would appreciate any help you can give me. Thanks.

3 Answers 3

29

On Heroku, you must set this line in your config/application.rb:

config.assets.initialize_on_precompile = false

http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets

For faster asset precompiles, you can partially load your application by setting config.assets.initialize_on_precompile to false in config/application.rb, though in that case templates cannot see application objects or methods. Heroku requires this to be false.

Sign up to request clarification or add additional context in comments.

1 Comment

need to commit an app after added about this line.
0

It means put in the name of a database that doesn't actually exist in your local dev environment. Then try and run rake assets:precompile

You're simulating the same scenario locally (an unavailable db).

Are you using Devise in this app? It had a known issue similar to this. You may want to update that gem.

1 Comment

I saw that issue as well, but I'm not using Devise. Do I need to put anything in the db that doesn't exist? Currently I have one for development, test and production like... development: adapter: sqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000
0

I ran into the same problem. It seems that for some reason the DATABASE_URL environment variable is not set at the time of asset precompilation. A workaround is to set the DATABASE_URL in the production.rb file. ENV["DATABASE_URL"] = <your db url> That should fix the problem.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.