Rails 7.1 Introduces Default Health Check Controller

All of us have at some point deployed our applications to cloud providers, we may have come across the term “health checks”.

Load Balancers determine whether to route traffic to the application based on the health check. Also, it can decide to restart the application if it is not responding or errors out. For that, it needs an endpoint that returns a 200 status code.


Previously, we would have to develop a controller and a route in order to give a health check end point.

# config/routes.rb
get '/health_check', to: 'health_check#show'
# app/controllers/health_check_controller.rb
class HealthCheckController < ApplicationController
  rescue_from(Exception) { render head: 503 }

  def show
    render head: 200


With the latest changes, we can use the default health check controller provided by Rails in version 7.1. This default health check controller is available at /up.

We can now visit /up to check whether the app is running. If the application is healthy, it will return a 200 status code. Else, it will return a 503 status code.

This helps us eliminate the need to create a custom health check endpoint and let Rails handle it.

Check out the PR and the guide PR for more details.

Need help on your Ruby on Rails or React project?

Join Our Newsletter