I have been trying to fix application errors on heroku (ruby on rails app) for the last 4 hours with no luck.
P.S The application runs perfectly fine locally
2023-10-30T14:40:44.484063+00:00 heroku[web.1]: State changed from up to crashed
2023-10-30T14:40:44.378048+00:00 heroku[router]: at=info method=GET path="/cable" host=j-a-m-1f39b9aba9a4.herokuapp.com request_id=2b4b5435-b40a-431c-b48f-1159fa5fd7fb fwd="86.182.36.176" dyno=web.1 connect=0ms service=107ms status=101 bytes=174 protocol=https
2023-10-30T14:41:19.466343+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/cable" host=j-a-m-1f39b9aba9a4.herokuapp.com request_id=41cf02af-42a1-43b5-9ac8-7d6fbf8ac59f fwd="86.182.36.176" dyno= connect= service= status=503 bytes= protocol=https
2023-10-30T14:41:19.652461+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/cable" host=j-a-m-1f39b9aba9a4.herokuapp.com request_id=3fd8c5e8-b470-4c2c-86cd-a6c5ac86246b fwd="86.182.36.176" dyno= connect= service= status=503 bytes= protocol=https
2023-10-30T14:41:27.250890+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/cable" host=j-a-m-1f39b9aba9a4.herokuapp.com request_id=255ce216-77ae-465a-9abb-f32e5b027221 fwd="86.182.36.176" dyno= connect= service= status=503 bytes= protocol=https
I have tried restarting heroku numerous times, ensured my storage.yml file is formatted correctly, found no error in heroku console. It may be to do with my procfile, but everything I have tried returns the same error. I also restarted all web dynos on heroku interface.
Procfile: web: bundle exec puma -C config/puma.rb
gemfile:
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'sqlite3'
ruby "3.1.2"
gem "devise"
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.7", ">= 7.0.7.2"
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"
# Use postgresql as the database for Active Record
# gem "pg", "~> 1.1"
group :production do
gem 'pg'
gem 'redis', '~> 4.0'
end
# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.0"
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails"
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails"
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"
# Use Redis adapter to run Action Cable in production
# gem "redis", "~> 4.0"
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false
# Use Sass to process CSS
gem "sassc-rails"
gem 'sidekiq'
gem 'thin'
# added faker
gem "faker"
gem "rails-ujs"
# spotify api
# gem 'rack-cors'
# gem 'active_model_serializers'
# gem 'rspotify'
# added cloudinary
gem "cloudinary"
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"
gem "bootstrap", "~> 5.2"
gem "autoprefixer-rails"
gem "font-awesome-sass", "~> 6.1"
gem "simple_form", github: "heartcombo/simple_form"
group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]
gem "dotenv-rails"
end
group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
# gem "rack-mini-profiler"
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"
end
group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "selenium-webdriver"
gem "webdrivers"
end
SOLUTION: I have fixed the app. The problem was my puma file was set up for development when it should have been production. The Procfile in my project specifies a command for the 'web' process type, which is responsible for running the application server.
The command, 'bundle exec puma -C config/puma.rb,' tells Puma how to start the application. However, I noticed that the configuration in the Puma file (config/puma.rb) is set up for development.
To ensure proper production settings, I have adjusted the Puma configuration in the config/puma.rb file to match the production environment's requirements.
All I did was change where it said development to production and uncommented out preload_app!. Here is my Puma file now: