How To Track Timeouts In Honeybadger

Most people consider timeouts to be a kind of error, so it'd be nice to have them reported by Honeybadger like any other errors. This article will show you how to set that up.

The other day a long-time customer wrote in with a problem. They use Honeybadger to monitor their Ruby apps for exceptions but were having trouble catching timeouts. If their app took too long to respond, their application server, Puma, would abort the request. The only insight their team had into this problem was through Puma's logs.

Most people consider timeouts to be a kind of error, so it'd be nice to have them reported by Honeybadger like any other errors. This article will show you how to set that up.

What are timeouts?

When a user requests a webpage, and your app doesn't respond in time, the infrastructure that serves your app assumes something went wrong and kills the request. This process is called a timeout.

Timeouts aren't always caused by errors. The user may have asked your application to perform a task that legitimately takes five minutes. However, web apps aren't usually engineered to handle such long requests, so they abort them after some amount of time: 5, 10, 20 seconds.

The tricky thing about timeouts is that they can originate outside of your application code.

In a Ruby web application, requests typically flow from a web server (like Nginx) to your application server (like unicorn) and from there to your rack application (which is where your code lives).

As you can see, Honeybadger lives inside your application. If your web server or application server cancel the request, there's no way for us to know about it.

How to report timeouts to Honeybadger

We know that Honeybadger can't report timeouts that happen outside the application, but what if they came from inside the application? That's what the rack-timeout gem is built to do.

To install rack-timeout in your Rails app, add this line to your Gemfile:

gem "rack-timeout"

You can configure the timeout values. Here, we set the service timeout to 60 seconds:


Now, if our rack application takes more than 60 seconds to respond to a request, rack-timeout raises a Rack::Timeout::RequestTimeoutException, which is reported to Honeybadger.

The rack-timeout gem has quite a few advanced options, as you'd expect from a project maintained by Heroku. Go check them all out!

Use timeouts carefully

Request timeouts are a very blunt instrument. Because they can interrupt your code at any point, they can result in state corruption and other nasty side-effects. You should only use them in the worst case scenario: when you're reasonably sure that the request has hung and not killing it might degrade service for your other users.

Any timeout that you can anticipate, such as a network or an IO timeout should be handled gracefully in your code.

What to do next:
  1. Try Honeybadger for FREE
    Honeybadger helps you find and fix errors before your users can even report them. Get set up in minutes and check monitoring off your to-do list.
    Start free trial
    Easy 5-minute setup — No credit card required
  2. Get the Honeybadger newsletter
    Each month we share news, best practices, and stories from the DevOps & monitoring community—exclusively for developers like you.
    author photo

    Starr Horne

    Starr Horne is a Rubyist and Chief JavaScripter at When she's not neck-deep in other people's bugs, she enjoys making furniture with traditional hand-tools, reading history and brewing beer in her garage in Seattle.

    More articles by Starr Horne
    Stop wasting time manually checking logs for errors!

    Try the only application health monitoring tool that allows you to track application errors, uptime, and cron jobs in one simple platform.

    • Know when critical errors occur, and which customers are affected.
    • Respond instantly when your systems go down.
    • Improve the health of your systems over time.
    • Fix problems before your customers can report them!

    As developers ourselves, we hated wasting time tracking down errors—so we built the system we always wanted.

    Honeybadger tracks everything you need and nothing you don't, creating one simple solution to keep your application running and error free so you can do what you do best—release new code. Try it free and see for yourself.

    Start free trial
    Simple 5-minute setup — No credit card required

    Learn more

    "We've looked at a lot of error management systems. Honeybadger is head and shoulders above the rest and somehow gets better with every new release."
    — Michael Smith, Cofounder & CTO of YvesBlue

    Honeybadger is trusted by top companies like: