Heroku has changed how they handle free dynos multiple times over the years, so you'd be excused for being a little lost about the current state of things. This guide will explain everything you need to know about Heroku free dynos and how to leverage them for the most value.
If you don't have time for the nitty gritty, here's the tldr:
You can run a web app 24/7 for free on Heroku, as long as you only run a web process and you have very modest database needs.
Want to know how? Let's dive in.
- What are free dynos?
- Free dyno limitations
- How to prevent free dynos from sleeping/idling
- How are free dyno hours calculated?
- Check your free dyno usage
- Free vs. Hobby vs. Standard dynos
- Running a production app on free dynos
- Using free dynos with Heroku's free Postgres database
- When and how to upgrade from free dynos
Free dynos are the entry-level tier of Heroku's six dyno types. Every Heroku app runs on "dynos", which is just Heroku's word for a container.
|Dyno Type||Monthly Cost|
Each of their six dyno types has an associated monthly cost. You choose which dyno type for your app, and how many dynos to diestribute the load.
Running a free dyno literally costs you nothing, and it will always cost you nothing. There's no way to be charged for running a free dyno.
Naturally, "free" comes with some limitations.
- Free web dynos will idle (sleep) after a period of inactivity. The next request will wake it up, but users will notice a significant delay while the app is started.
- You have a limited number of "free dyno hours" each month. When you've exhausted your quota, your app shuts down.
- Free dynos are not available for Heroku Teams.
- Free dynos do not support Heroku SSL for custom domains.
Those limitations might seem like dealbreakers, but fear not! We have workarounds for many of them.
Free dynos will sleep (shut down) after 30 minutes of inactivity. This is actually a feature to avoid using up your free dyno hours on a rarely-used app. It's why free dynos are great for staging/test environments.
If you want your free web dynos to run 24/7, you'll need to ensure they receive continual traffic. The easiest way to do so is using an uptime monitor that pings your app all day long.
There are lots of uptime monitor services, and there's a good chance you're already using one. If you need a free one (you're reading about free dynos, right?), I've had success with free plans from Freshping and UptimeRobot.
Note that this restriction only applies to web dynos. If you're running a "worker" dyno (asynchronous job processing), it will not go to sleep. It's very easy to consume your free dyno hours quota with worker dynos.
Heroku prorates dyno usage to the second. If you run a free dyno for 30 minutes, that'll use 0.5 hours from your free dyno hours quota. If you run an app with single free dyno 24/7 for 30 days, that'll use 720 (24 * 30) of your free dyno hours.
So how many free dyno hours do you get?
From the official docs:
Accounts are given a base of 550 free dyno hours each month. In addition to these base hours, accounts which verify with a credit card will receive an additional 450 hours added to the monthly free dyno quota. This means you can receive a total of 1000 free dyno hours per month, if you verify your account with a credit card.
In 2015-2016 there was a time when free dynos could only run 18 hours a day, but this is no longer the case. Free dynos will run 24 hours a day as long as you have sufficient hours available in your quota.
If you had a free app running when these new rules launched in 2016, you may have been grandfathered in and have more than 1000 free dyno hours available to you. Lucky you!
So how many free dyno hours do you have available? Check out your Heroku billing page.
This is a great way to check up on any forgotten apps that are consuming your free dynos quota!
Heroku's six dyno types are generally more powerful as they get more expensive, but that's not the case for cheapest three.
Free, Hobby, and Standard-1X dynos are exactly the same hardware with the same performance characteristics. Hobby dynos lift some of the feature limitations of Free dynos:
- Hobby dynos do not go to sleep.
- Hobby dynos support Heroku SSL for custom domains.
- There's no "quota" for Hobby dynos.
One shared limitation between Free and Hobby dynos is that you cannot scale to more than one dyno per process. If you need to scale to two web dynos, for example, you must use standard or performance dynos.
- Heroku's SSL for custom domains is only available on paid plans. I use Cloudflare's free SSL, which makes this a non-issue. It's also a non-issue if you want to use the default *.herokuapp.com domain, which always supports SSL.
- Heroku's metrics tab is only available on paid plans. Check out Librato's free add-on for similar metrics.
- Free (and hobby) dynos can't be scaled up to multiple dynos. You can only run a single dyno of each type (web, worker, etc.). If you've outgrown a single dyno, though, you're hopefully making some revenue and can start investing in your hosting.
This means you can run the equivalent of a standard dyno for free for 1,000 hours per month. With 744 hours in a 31-day month, that means you can run your production app 24/7 on Heroku for free, right?
Well, that depends.
Most production apps need at least a web process and a background worker process for things like sending email and processing payments. That's two dynos running for 744 hours per month, which exceeds your 1,000 hour allotment. Free worker dynos do not automatically idle like free web dynos do, so they'll be running 24/7 unless you manually scale them down.
This is where you need to decide just how "production-scale" your app needs to be right now. You could perform this work synchronously within your web process instead of backgrounding it, or you find a way to run async jobs within your web process. Some background work could also be performed on a periodic basis with Heroku Scheduler, which only uses dyno hours for the time it's running.
If you really do need a separate worker process (many production apps do), then you've probably outgrown free dynos.
Want notified when I write more articles like this one? Sign up for my Mastering Heroku mailing list! Very infrequent, very relevant, no sales pitches.
We also need to talk about your database. Heroku's free Postgres offering is limited to 10,000 records. Yeah... that hurts.
Even the smallest production apps are likely going to exceed this limitation. Here are your options:
- Upgrade to a paid Heroku database plan, starting at \$9/month for 10,000,000 records.
- Use a third-party hosted database provider with a more generous free plan, like ElephantSQL.
I personally think Heroku's Postgres plans are worth every penny, but I also know firsthand the cost can be hard to swallow when launching a side project with no revenue.
So with all this in mind, when do Heroku's free offerings make sense for you?
- Launching a side project. There's a good chance the side project won't get much traction, so throw it on free dynos and a free Postgres DB and see what happens! You won't have enough free hours to run worker dynos, but who cares... until you have real users, you can do everything in your web process.
- Running a staging or QA app. These are perfect for free dynos because they don't need to run all the time. Your staging data might even fit within a free Postgres DB.
Beyond those use cases, you're probably going to have to pay for Heroku. The free options exist to try out the service, play with an idea, and run experiments. Once you're running a "real app", you should be at a point where you can spend a few dollars on hosting. You'll still be spending a whole lot less than the engineering time required to manage your own production environment.