Rails: Rack::Timeout::RequestTimeoutException: Request ran for 15001ms, exceeding the 15000ms timeout (Heroku H12)
A request took longer than rack-timeout's limit (or Heroku's 30 s router timeout), so it was aborted.
Rack::Timeout::RequestTimeoutException: Request ran for 15001ms, exceeding the 15000ms timeoutRequest waited too long in queue Rack::TimeoutHeroku H12 Request timeout Meaning
Find slow code: N+1 queries, slow external APIs, big exports. Move heavy work to background jobs (Sidekiq/ActiveJob), add indexes, caches and timeouts on HTTP clients. Tune RACK_TIMEOUT_SERVICE_TIMEOUT only after fixing causes. Heroku H12 means the router gave up after 30 s.
Common causes
- N+1 queries or missing DB indexes
- Slow third-party API without timeouts
- Long exports/reports in a request
- Cold boot/memory pressure
- Too few workers/threads causing queueing
⚡ Quick fix
- Profile with
rack-mini-profiler/APM; fix N+1 (includes) - Use background jobs for long tasks
- Set client timeouts (Faraday/Net::HTTP)
Detailed fix by platform
Rails
config.middleware.insert_before Rack::Runtime, Rack::Timeout, service_timeout: 20
How to diagnose
- Cause — DB/API/CPU?
- Queue — Request queueing?
- Fix — Background job?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 2006 MySQL ERROR 2006 (HY000): MySQL server has gone away
- 2013 MySQL ERROR 2013 (HY000): Lost connection to MySQL server during query
- 499 Client Closed Request / client prematurely closed connection Nginx: [info] client prematurely closed connection while reading response header from upstream / access log status 499
Most viewed in Ruby / Rails
- ActiveRecord::PendingMigrationError Rails: ActiveRecord::PendingMigrationError — Migrations are pending. To resolve this issue, run: bin/rails db:migrate
- undefined method for nil Ruby: NoMethodError: undefined method `x' for nil (nil:NilClass)
- ActionController::InvalidAuthenticityToken Rails: ActionController::InvalidAuthenticityToken (Can't verify CSRF token authenticity)
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026