Skip to content
🚀 Limited-time offer $130 for Lifetime Pro access. Buy once and use forever

Status List

Uptime & Status Pages

Rails-HealthCheck Setup Guide

You need to know if your Rails application is working. Rails health checks allows your app to self heal and notify you about issues. Let’s set it up!

This guide uses the Rails-Healthcheck gem. If you would rather use the built-in Rails::HealthController, please refer to our Rails Health Check Setup Guide.


Install Rails-HealthCheck Gem

Add the following to your Gemfile:
					gem 'rails-healthcheck'
Setup your new gem with the rails generate command:
					rails generate healthcheck:install

Customize Route

Open the initializer file at config/initializers/healthcheck.rb. Update the .route property to /up. Set verbose=true to we can diagnose any errors. Save your changes and restart your app. Open You should get an output that looks like this:
Rails Health Check basic

Add Health Checks

Next, we need to add checks for the services we rely on. Open up your healthcheck.rb initializer, again. In the bottom section, let’s add checks for database, cache and our mail service.
Ready to know about downtime before your customers?
Status List delivers uptime monitoring and professional hosted status pages for sites of all shapes and sizes.

Trusted by 1000+ companies

Database Health Check

healthcheck.rb comes with a pre-built example to test ActiveRecord. You can uncomment the 2 lines below:
					config.add_check :database,     -> { ActiveRecord::Base.connection.execute('select 1') }
config.add_check :migrations,   -> { ActiveRecord::Migration.check_pending! }

Cache Health Check

healthcheck.rb comes with a pre-built example to test our Rails.cache. You can uncomment the line below:
					config.add_check :cache,        -> {'some_key') }

Mail Service Check

Let’s add a check for our mail service. Your mail service may be different, but you can follow the template below. We’re just going to ping an reporting endpoint and make sure it replies with an OK status.
					config.add_check :mail_service, -> {
    response = Net::HTTP.get_response(URI.parse(""), {
        'Authentication' => ENV['MAILGUN_API_KEY'],
    return response.error!

Test Health Check

Restart your app to refresh the HealthCheck configuration. Open and you should a json response with an http status of 200. This is what mine looks like:
Rails Health Check Verbose

Setup Uptime Monitor

Once you have your checks setup, it’s time to setup your uptime monitor. Log into your uptime service and add monitors for both of your services. You’ll want to check both /health/app and /health/upstream separately. You may also want to configure a minimum response time for /health/app to ensure your app is responsive.

You may also want to show your app’s status on your status page. Ensure you update your status page configuration to pull your uptime stats in to your status page.

Putting it all together

You now have uptime checks and alerts for your Rails application. If your app runs into issues you’ll be the first to know.

You may also be interested in our Heroku Uptime Service.