Search code examples
ruby-on-railsrubyherokuactiverecordrubygems

How to resolve 500 status when deploying to Heroku


2023-02-15T20:31:47.060556+00:00 app[web.1]: I, [2023-02-15T20:31:47.060491 #2]  INFO -- : [f8806da7-4389-4a8f-b176-19ed6c60103f] Started GET "/users/sign_up" for 66.249.64.84 at 2023-02-15 20:31:47 +0000
2023-02-15T20:31:47.061344+00:00 app[web.1]: I, [2023-02-15T20:31:47.061287 #2]  INFO -- : [f8806da7-4389-4a8f-b176-19ed6c60103f] Processing by RegistrationsController#new as HTML
2023-02-15T20:31:47.062452+00:00 app[web.1]: D, [2023-02-15T20:31:47.062413 #2] DEBUG -- : [f8806da7-4389-4a8f-b176-19ed6c60103f]    (0.1ms)  SELECT sqlite_version(*)
2023-02-15T20:31:47.062848+00:00 app[web.1]: I, [2023-02-15T20:31:47.062814 #2]  INFO -- : [f8806da7-4389-4a8f-b176-19ed6c60103f] Completed 500 Internal Server Error in 1ms (ActiveRecord: 0.3ms | Allocations: 527)
2023-02-15T20:31:47.063561+00:00 app[web.1]: F, [2023-02-15T20:31:47.063527 #2] FATAL -- : [f8806da7-4389-4a8f-b176-19ed6c60103f]
2023-02-15T20:31:47.063561+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] ActiveRecord::StatementInvalid (Could not find table 'users'):
2023-02-15T20:31:47.063562+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f]
2023-02-15T20:31:47.063562+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/sqlite3_adapter.rb:346:in `table_structure'
2023-02-15T20:31:47.063563+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/abstract/schema_statements.rb:116:in `columns'
2023-02-15T20:31:47.063563+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/schema_cache.rb:112:in `block in columns'
2023-02-15T20:31:47.063563+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/schema_cache.rb:111:in `fetch'
2023-02-15T20:31:47.063564+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/schema_cache.rb:111:in `columns'
2023-02-15T20:31:47.063564+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/schema_cache.rb:120:in `block in columns_hash'
2023-02-15T20:31:47.063564+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/schema_cache.rb:119:in `fetch'
2023-02-15T20:31:47.063564+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/connection_adapters/schema_cache.rb:119:in `columns_hash'
2023-02-15T20:31:47.063565+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/model_schema.rb:553:in `load_schema!'
2023-02-15T20:31:47.063566+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/attributes.rb:250:in `load_schema!'
2023-02-15T20:31:47.063566+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/model_schema.rb:539:in `block in load_schema'
2023-02-15T20:31:47.063566+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/model_schema.rb:536:in `synchronize'
2023-02-15T20:31:47.063567+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/model_schema.rb:536:in `load_schema'
2023-02-15T20:31:47.063567+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/model_schema.rb:402:in `attribute_types'
2023-02-15T20:31:47.063567+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/attribute_methods.rb:187:in `_has_attribute?'
2023-02-15T20:31:47.063567+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/inheritance.rb:57:in `new'
2023-02-15T20:31:47.063567+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] devise (4.8.1) lib/devise/models/registerable.rb:22:in `new_with_session'
2023-02-15T20:31:47.063568+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] devise (4.8.1) app/controllers/devise/registrations_controller.rb:100:in `build_resource'
2023-02-15T20:31:47.063568+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] devise (4.8.1) app/controllers/devise/registrations_controller.rb:10:in `new'
2023-02-15T20:31:47.063568+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
2023-02-15T20:31:47.063568+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/abstract_controller/base.rb:228:in `process_action'
2023-02-15T20:31:47.063568+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_controller/metal/rendering.rb:30:in `process_action'
2023-02-15T20:31:47.063569+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
2023-02-15T20:31:47.063569+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/callbacks.rb:117:in `block in run_callbacks'
2023-02-15T20:31:47.063569+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actiontext (6.1.7.2) lib/action_text/rendering.rb:20:in `with_renderer'
2023-02-15T20:31:47.063570+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actiontext (6.1.7.2) lib/action_text/engine.rb:59:in `block (4 levels) in <class:Engine>'
2023-02-15T20:31:47.063570+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/callbacks.rb:126:in `instance_exec'
2023-02-15T20:31:47.063570+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/callbacks.rb:126:in `block in run_callbacks'
2023-02-15T20:31:47.063570+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/callbacks.rb:137:in `run_callbacks'
2023-02-15T20:31:47.063570+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/abstract_controller/callbacks.rb:41:in `process_action'
2023-02-15T20:31:47.063573+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_controller/metal/rescue.rb:22:in `process_action'
2023-02-15T20:31:47.063573+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
2023-02-15T20:31:47.063573+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/notifications.rb:203:in `block in instrument'
2023-02-15T20:31:47.063574+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
2023-02-15T20:31:47.063574+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/notifications.rb:203:in `instrument'
2023-02-15T20:31:47.063574+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_controller/metal/instrumentation.rb:33:in `process_action'
2023-02-15T20:31:47.063574+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
2023-02-15T20:31:47.063575+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activerecord (6.1.7.2) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
2023-02-15T20:31:47.063575+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/abstract_controller/base.rb:165:in `process'
2023-02-15T20:31:47.063575+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionview (6.1.7.2) lib/action_view/rendering.rb:39:in `process'
2023-02-15T20:31:47.063575+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_controller/metal.rb:190:in `dispatch'
2023-02-15T20:31:47.063576+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_controller/metal.rb:254:in `dispatch'
2023-02-15T20:31:47.063576+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
2023-02-15T20:31:47.063576+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/routing/route_set.rb:33:in `serve'
2023-02-15T20:31:47.063576+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>'
2023-02-15T20:31:47.063576+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/routing/mapper.rb:49:in `serve'
2023-02-15T20:31:47.063577+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/journey/router.rb:50:in `block in serve'
2023-02-15T20:31:47.063577+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/journey/router.rb:32:in `each'
2023-02-15T20:31:47.063577+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/journey/router.rb:32:in `serve'
2023-02-15T20:31:47.063577+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/routing/route_set.rb:842:in `call'
2023-02-15T20:31:47.063577+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/deflater.rb:44:in `call'
2023-02-15T20:31:47.063578+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] warden (1.2.9) lib/warden/manager.rb:36:in `block in call'
2023-02-15T20:31:47.063578+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] warden (1.2.9) lib/warden/manager.rb:34:in `catch'
2023-02-15T20:31:47.063578+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] warden (1.2.9) lib/warden/manager.rb:34:in `call'
2023-02-15T20:31:47.063578+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/tempfile_reaper.rb:15:in `call'
2023-02-15T20:31:47.063579+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/etag.rb:27:in `call'
2023-02-15T20:31:47.063579+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/conditional_get.rb:27:in `call'
2023-02-15T20:31:47.063579+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/head.rb:12:in `call'
2023-02-15T20:31:47.063579+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/http/permissions_policy.rb:22:in `call'
2023-02-15T20:31:47.063579+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/http/content_security_policy.rb:19:in `call'
2023-02-15T20:31:47.063579+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/session/abstract/id.rb:266:in `context'
2023-02-15T20:31:47.063579+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/session/abstract/id.rb:260:in `call'
2023-02-15T20:31:47.063580+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/cookies.rb:697:in `call'
2023-02-15T20:31:47.063580+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
2023-02-15T20:31:47.063580+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/callbacks.rb:98:in `run_callbacks'
2023-02-15T20:31:47.063580+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
2023-02-15T20:31:47.063583+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
2023-02-15T20:31:47.063583+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
2023-02-15T20:31:47.063583+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
2023-02-15T20:31:47.063583+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] railties (6.1.7.2) lib/rails/rack/logger.rb:37:in `call_app'
2023-02-15T20:31:47.063584+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] railties (6.1.7.2) lib/rails/rack/logger.rb:26:in `block in call'
2023-02-15T20:31:47.063584+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/tagged_logging.rb:99:in `block in tagged'
2023-02-15T20:31:47.063584+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/tagged_logging.rb:37:in `tagged'
2023-02-15T20:31:47.063584+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/tagged_logging.rb:99:in `tagged'
2023-02-15T20:31:47.063584+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] railties (6.1.7.2) lib/rails/rack/logger.rb:26:in `call'
2023-02-15T20:31:47.063584+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
2023-02-15T20:31:47.063584+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/request_id.rb:26:in `call'
2023-02-15T20:31:47.063585+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/method_override.rb:24:in `call'
2023-02-15T20:31:47.063585+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/runtime.rb:22:in `call'
2023-02-15T20:31:47.063585+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] activesupport (6.1.7.2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
2023-02-15T20:31:47.063585+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
2023-02-15T20:31:47.063585+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/static.rb:24:in `call'
2023-02-15T20:31:47.063585+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] rack (2.2.6.2) lib/rack/sendfile.rb:110:in `call'
2023-02-15T20:31:47.063585+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/ssl.rb:77:in `call'
2023-02-15T20:31:47.063586+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] actionpack (6.1.7.2) lib/action_dispatch/middleware/host_authorization.rb:142:in `call'
2023-02-15T20:31:47.063586+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] railties (6.1.7.2) lib/rails/engine.rb:539:in `call'
2023-02-15T20:31:47.063586+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] puma (4.3.12) lib/puma/configuration.rb:228:in `call'
2023-02-15T20:31:47.063586+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] puma (4.3.12) lib/puma/server.rb:727:in `handle_request'
2023-02-15T20:31:47.063586+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] puma (4.3.12) lib/puma/server.rb:476:in `process_client'
2023-02-15T20:31:47.063586+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] puma (4.3.12) lib/puma/server.rb:332:in `block in run'
2023-02-15T20:31:47.063586+00:00 app[web.1]: [f8806da7-4389-4a8f-b176-19ed6c60103f] puma (4.3.12) lib/puma/thread_pool.rb:134:in `block in spawn_thread'

Ruby app was previously on Heroku-18 stack and deprecated a few months ago. I upgraded to Heroku-22 stack on yesterday and have not had any success being able to login or sign up to the app. The app successfully deploys to Heroku and I can access the homepage but when I navigate to enter information to be stored in the database I receive the, "We're sorry, but something went wrong", error.

When I run the Heroku logs command I receive the above print out for the logs. I've updated the ruby gem version and rails version on the app as well.

I'm not sure how to fix/correct the issues?


Solution

  • It looks like your application is configured to use SQLite as database adapter and that there was no database found. Using SQLite will certainly not work because of Heroku's ephemeral file system (unless it is a read-only database).

    Instead, the most common and best documented option is to use a Heroku PostgreSQL database that can be added as an add-on. Alternatively, there are other many other database add-ons available, or you could configure a database running on your own server or, for example, on an AWS RDS database.

    Assuming you want to use the Heroku Postgres option, you simply need to add the add-on to your application. And by doing so, Heroku will configure a DATABASE_URL environment variable and keep it updated for you.

    Within your application, you will need to do three things:

    1. Add the pg gem to your Gemfile and run bundle update. You might only want to add this gem to the production group in the Gemfile. But I suggest using Postgres in development and test environment too, to avoid running into issues because SQLite and Postgres behave differently in some cases.

    2. Then update your config/database.yml to use the DATABASE_URL set by Heroku to configure the database connection. That will likely have to look like this:

      production:
        adapter: postgresql
        url: <%= ENV['DATABASE_URL'] %>
      

      Commit and push those changes to Heroku.

    3. After deploying those changes, you will need to run migrations on Heroku by running heroku run rails db:migrate to start with an empty database, or you might want to import data from another database.

    I suggest reading about Ruby Database Provisioning and Heroku Postgres in the Heroku Dev Center.