Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku app crashed, receiving "Invalid DATABASE URL" when attempting heroku rake db:migrate

I'm new to Programming and was following the Rails Tutorial by Michael Hartl when I ran into this while attempting heroku rake db:migrate

(in /app)
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/file_utils.rb:10: warning: already initialized constant RUBY
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/file_utils.rb:84: warning: already initialized constant LN_SUPPORTED
rake aborted!
Invalid DATABASE_URL
(erb):9:in `rescue in <main>'
(erb):6:in `<main>'
/usr/ruby1.9.2/lib/ruby/1.9.1/erb.rb:753:in `eval'
/usr/ruby1.9.2/lib/ruby/1.9.1/erb.rb:753:in `result'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/application/configuration.rb:86:in `database_configuration'
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/railtie.rb:58:in `block (2 levels) in <class:Railtie>'
/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:42:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/base.rb:1867:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/migration.rb:486:in `initialize'
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/migration.rb:433:in `new'
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/migration.rb:433:in `up'
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/migration.rb:415:in `migrate'
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/railties/databases.rake:142:in `block (2 levels) in <top (required)>'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:634:in `call'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:634:in `block in execute'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:629:in `each'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:629:in `execute'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:595:in `block in invoke_with_call_chain'
/usr/ruby1.9.2/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:581:in `invoke'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2041:in `invoke_task'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2019:in `block (2 levels) in top_level'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2019:in `each'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2019:in `block in top_level'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2013:in `top_level'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1992:in `run'
/usr/ruby1.9.2/bin/rake:31:in `<main>' 

The application works perfectly on localserver but has crashed completely saying

An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

I get this error in logs

2011-06-13T20:20:47+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/initializable.rb:25:in `instance_exec'
2011-06-13T20:20:47+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/initializable.rb:25:in `run'
2011-06-13T20:20:47+00:00 heroku[web.1]: Process exited
2011-06-13T20:20:48+00:00 heroku[web.1]: State changed from starting to crashed
2011-06-13T20:21:29+00:00 heroku[router]: Error H10 (App crashed) -> GET deep-beach-590.heroku.com/ dyno= queue= wait= service= bytes=
2011-06-13T13:21:30-07:00 heroku[nginx]: GET / HTTP/1.1 | 86.44.102.112 | 796 | http | 503
2011-06-13T20:24:25+00:00 heroku[web.1]: State changed from crashed to created
2011-06-13T20:24:25+00:00 heroku[web.1]: State changed from created to starting
2011-06-13T20:24:31+00:00 heroku[web.1]: Starting process with command: `thin -p 16433 -e production -R /home/heroku_rack/heroku.ru start`

Anyone think they know what's causing the app to crash?

edit: with more logs after restart

2011-06-14T12:22:46+00:00 heroku[web.1]: State changed from starting to crashed
2011-06-14T12:32:32+00:00 heroku[web.1]: State changed from crashed to created
2011-06-14T12:32:32+00:00 heroku[web.1]: State changed from created to starting
2011-06-14T12:32:42+00:00 heroku[web.1]: Starting process with command: `thin -p 14587 -e production -R /home/heroku_rack/heroku.ru start`
2011-06-14T12:32:45+00:00 app[web.1]: (erb):9:in `rescue in <main>': Invalid DATABASE_URL (RuntimeError)
2011-06-14T12:32:45+00:00 app[web.1]:   from (erb):6:in `<main>'
2011-06-14T12:32:45+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/1.9.1/erb.rb:753:in `eval'
2011-06-14T12:32:45+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/1.9.1/erb.rb:753:in `result'
2011-06-14T12:32:45+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/application/configuration.rb:86:in `database_configuration'
2011-06-14T12:32:45+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/railtie.rb:58:in `block (2 levels) in <class:Railtie>'
2011-06-14T12:32:45+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
2011-06-14T12:32:45+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
2011-06-14T12:32:45+00:00 heroku[web.1]: Process exited
2011-06-14T12:32:46+00:00 heroku[web.1]: State changed from starting to crashed
2011-06-14T12:45:03+00:00 heroku[web.1]: State changed from crashed to created
2011-06-14T12:45:03+00:00 heroku[web.1]: State changed from created to starting
2011-06-14T12:45:08+00:00 heroku[web.1]: Starting process with command: `thin -p 15727 -e production -R /home/heroku_rack/heroku.ru start`
2011-06-14T12:45:11+00:00 app[web.1]: (erb):9:in `rescue in <main>': Invalid DATABASE_URL (RuntimeError)
2011-06-14T12:45:11+00:00 app[web.1]:   from (erb):6:in `<main>'
2011-06-14T12:45:11+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/1.9.1/erb.rb:753:in `eval' 
2011-06-14T12:45:11+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/1.9.1/erb.rb:753:in `result'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/application/configuration.rb:86:in `database_configuration'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/railtie.rb:58:in `block (2 levels) in <class:Railtie>'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:42:in `each'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/base.rb:1867:in `<top (required)>'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/app/models/user.rb:14:in `<top (required)>'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `block in require'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:227:in `load_dependency'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:346:in `require_or_load'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:300:in `depend_on'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:216:in `require_dependency'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/engine.rb:138:in `block (2 levels) in eager_load!'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/engine.rb:137:in `each'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/engine.rb:137:in `block in eager_load!'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/engine.rb:135:in `each'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/engine.rb:135:in `eager_load!'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/application.rb:108:in `eager_load!'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/application/finisher.rb:41:in `block in <module:Finisher>'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/initializable.rb:25:in `instance_exec'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/initializable.rb:25:in `run'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/initializable.rb:50:in `block in run_initializers'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/initializable.rb:49:in `each'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/initializable.rb:49:in `run_initializers'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/application.rb:134:in `initialize!'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/application.rb:77:in `method_missing'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/config/environment.rb:5:in `<top (required)>'
2011-06-14T12:45:11+00:00 app[web.1]:   from <internal:lib/rubygems/custom_require>:29:in `require'
2011-06-14T12:45:11+00:00 app[web.1]:   from <internal:lib/rubygems/custom_require>:29:in `require'
2011-06-14T12:45:11+00:00 app[web.1]:   from config.ru:3:in `block (3 levels) in <main>'
2011-06-14T12:45:11+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:23:in `eval'
2011-06-14T12:45:11+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:23:in `block (3 levels) in <main>'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.3/lib/rack/builder.rb:63:in `new'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.3/lib/rack/builder.rb:63:in `map'
2011-06-14T12:45:11+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:18:in `block (2 levels) in <main>'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval'
2011-06-14T12:45:11+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:11:in `block in <main>'
2011-06-14T12:45:11+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize'
2011-06-14T12:45:11+00:00 app[web.1]:   from /home/heroku_rack/heroku.ru:1:in `new'
2011-06-14T12:45:11+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:143:in `run!'
2011-06-14T12:45:11+00:00 app[web.1]:   from /usr/ruby1.9.2/bin/thin:19:in `load'
2011-06-14T12:45:11+00:00 heroku[web.1]: Process exited
2011-06-14T12:45:11+00:00 heroku[web.1]: State changed from starting to crashed
2011-06-14T12:45:11+00:00 heroku[web.1]: State changed from crashed to created
2011-06-14T12:45:11+00:00 heroku[web.1]: State changed from created to starting
2011-06-14T12:45:16+00:00 heroku[web.1]: Starting process with command: `thin -p 46054 -e production -R /home/heroku_rack/heroku.ru start`
2011-06-14T12:45:20+00:00 app[web.1]: (erb):9:in `rescue in <main>': Invalid DATABASE_URL (RuntimeError)
2011-06-14T12:45:20+00:00 app[web.1]:   from (erb):6:in `<main>'
2011-06-14T12:45:20+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/1.9.1/erb.rb:753:in `eval'
2011-06-14T12:45:20+00:00 app[web.1]:   from /usr/ruby1.9.2/lib/ruby/1.9.1/erb.rb:753:in `result'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/application/configuration.rb:86:in `database_configuration'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/railtie.rb:58:in `block (2 levels) in <class:Railtie>'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:42:in `each'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/base.rb:1867:in `<top (required)>'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/app/models/user.rb:14:in `<top (required)>'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `block in require'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:227:in `load_dependency'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:346:in `require_or_load'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:300:in `depend_on'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:216:in `require_dependency'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/engine.rb:138:in `block (2 levels) in eager_load!'
2011-06-14T12:45:20+00:00 app[web.1]:   from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.1/lib/rails/engine.rb:137:in `each'
2011-06-14T12:45:20+00:00 heroku[web.1]: Process exited
2011-06-14T12:45:21+00:00 heroku[web.1]: State changed from starting to crashed
2011-06-14T12:45:21+00:00 heroku[router]: Error H10 (App crashed) -> GET deep-beach-590.heroku.com/ dyno= queue= wait= service= bytes=
2011-06-14T05:45:21-07:00 heroku[nginx]: GET / HTTP/1.1 | 86.44.102.112 | 796 | http | 503
2011-06-14T12:45:21+00:00 heroku[router]: Error H10 (App crashed) -> GET deep-beach-590.heroku.com/favicon.ico dyno= queue= wait= service= bytes=

I think the simpler solution here might be to destroy the app and start again.

like image 906
fnln Avatar asked Jun 13 '11 20:06

fnln


2 Answers

Most likely you are missing the shared-database addon.

heroku addons:add shared-database

See https://devcenter.heroku.com/articles/database#troubleshooting

like image 58
fotanus Avatar answered Sep 22 '22 11:09

fotanus


Make sure your DB URL is correctly formated, see this answer:

How to connect to postgresql using url

Try heroku db:push postgres://username:password@localhost/myrailsdb.

like image 22
MatthewFord Avatar answered Sep 23 '22 11:09

MatthewFord