Keep Alive

Heroku Guide

Keep your Heroku dynos responsive and prevent cold starts.

Heroku Dyno Cold Start Prevention Guide

For developers using Heroku's free and hobby tiers.

Why do Heroku dynos sleep?

Free tier Heroku dynos automatically sleep after 30 minutes of inactivity. They also sleep 6 hours in any 24-hour period regardless of traffic (as of Heroku's policy changes).

What happens when a dyno sleeps?

When a sleeping dyno receives traffic, Heroku must wake it up - taking 10-30 seconds. During this time, users see a loading screen or timeout.

How does Keep Alive prevent Heroku dyno sleep?

Keep Alive sends HTTP requests to your Heroku app before the 30-minute inactivity timeout is reached:

  • Configurable ping intervals (25 minutes recommended for Heroku)
  • Works with any Heroku stack/language
  • No code changes required
  • Dashboard shows uptime statistics

Setup guide

  1. Add your Heroku app URL to Keep Alive
  2. Set ping interval to 25 minutes
  3. Optionally create a lightweight health endpoint
  4. Monitor response times to verify dyno remains awake

Important Heroku limitations

The 6-hour sleep quota per 24 hours on free tier cannot be circumvented by pinging. For production apps requiring 24/7 uptime, consider Heroku's Eco or Basic plans. Keep Alive will still optimize uptime within free tier constraints.

Best practices for Heroku apps

  • Strategic pinging: If you have usage patterns, time your pings during likely user hours
  • Quick startup: Optimize your app's boot time for faster recovery from sleep
  • Multiple dynos: For complex apps, ping each service separately
  • Database connections: Use connection pooling to handle reconnects after sleep

Heroku-specific tips

Beyond basic pinging, these strategies can help with Heroku free tier:

  • Worker dynos: Use separate worker dynos for background tasks (they have different sleep policies)
  • Memory leaks: Heroku's R14 errors are more common on free dynos - fix memory leaks
  • Startup hooks: Implement proper startup hooks to handle post-sleep initialization
  • Timeout handling: Implement progressive timeout handling in your app

Heroku vs other platforms

Heroku's free tier has specific limitations compared to other platforms, but Keep Alive can still help:

  • Heroku: 30 minutes + 6hr quota → Partially mitigated with Keep Alive
  • Render: 15 minutes → Fully mitigated with Keep Alive
  • Lambda: No explicit sleep policy, but containers recycle → Fully mitigated