Heroku应用程序崩溃,在尝试heroku rake db:migrate时收到“无效的DATABASE URL”

我是编程的新手,当我尝试使用heroku rake db:migrate时遇到了这个问题,我正在关注Michael Hartl的Rails教程

(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 ' (erb):6:in `' /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 ' /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 `' /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 ' /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 `' 

该应用程序在localserver上完美运行但完全崩溃了

应用程序中发生错误,无法提供您的页面。 请稍后重试。

如果您是应用程序所有者,请检查日志以获取详细信息。

我在日志中收到此错误

 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` 

有人认为他们知道是什么导致应用程序崩溃吗?

编辑:重启后有更多日志

 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 ': Invalid DATABASE_URL (RuntimeError) 2011-06-14T12:32:45+00:00 app[web.1]: from (erb):6:in `' 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 ' 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 ': Invalid DATABASE_URL (RuntimeError) 2011-06-14T12:45:11+00:00 app[web.1]: from (erb):6:in `' 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 ' 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 `' 2011-06-14T12:45:11+00:00 app[web.1]: from /app/app/models/user.rb:14:in `' 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 ' 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 `' 2011-06-14T12:45:11+00:00 app[web.1]: from :29:in `require' 2011-06-14T12:45:11+00:00 app[web.1]: from :29:in `require' 2011-06-14T12:45:11+00:00 app[web.1]: from config.ru:3:in `block (3 levels) in ' 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 ' 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 ' 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 ' 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 ': Invalid DATABASE_URL (RuntimeError) 2011-06-14T12:45:20+00:00 app[web.1]: from (erb):6:in `' 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 ' 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 `' 2011-06-14T12:45:20+00:00 app[web.1]: from /app/app/models/user.rb:14:in `' 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= 

我认为这里更简单的解决方案可能是破坏应用程序并重新开始。

您很可能缺少共享数据库插件。

 heroku addons:add shared-database 

请参阅https://devcenter.heroku.com/articles/database#troubleshooting

确保您的数据库URL正确格式化,请参阅以下答案:

如何使用url连接到postgresql

试试heroku db:push postgres:// username:password @ localhost / myrailsdb。

我遇到了这个错误,我有一个名为“HEROKU_POSTGRESQL_COLOR”的开发计划数据库。 当我运行heroku pg:info ,它看起来是正确的,但我的rails应用程序崩溃时出现“无效的数据库URL”错误。

为了解决这个问题,我运行了C:\Users\Matt\heroku_apps\langural>heroku pg:promote HEROKU_POSTGRESQL_COLOR_URL ,它将dev数据库提升为“生产”状态,使其成为DATABASE_URL(以及HEROKU_POSTGRESQL_COLOR)的数据库。