Skip to main content

Keep Your Free Heroku App Alive

· 2 min read
koficodes
Just a person

Thanks to Heroku, now I have my personal site :)

Too bad, heroku no longer offer free dyno..

If an app has a free web dyno, and that dyno receives no web traffic in a 30-minute period, it will sleep.

Every Heroku account is allocated a pool of free dyno hours, which can be used by Personal apps - apps that are not part of a Heroku Team or Enterprise Team.

If you want to know more about free dyno hours, visit official site here

I am using a free tier account and I don't want my visitor to wait for dyno to re-launch everytime when they visit the site. This is the method I used for keeping my site alive.

  • Signup on https://cron-job.org/en/
  • Once the signup is completed, verify your email.
  • Once you log in successfully, click on the Cronjobs tab. And click on “Create cronjob”.

cron-job

  • Now you can fill in the details. Make sure you enter URL according to your GET method. If your GET method was for route “/home,” make sure your URL is https://your-app.herokuapp.com/home.

If you are not verifying Heroku app with your credit card, you might want to go for user-defined schedule.

  • When you reach the Schedule section, click on the option User-defined. Now make sure you select all the values in the columns Days of Month Days of Week, and Months.
  • In the Hours column, select all values except for any seven. I selected all values except for 0,1,2,3,4,5,6, which means my app will be asleep from 12 a.m. to 7 a.m. (no job at 6 a.m. means the app will be asleep at 6 a.m.). This step is essential as it satisfies the restriction for the free tier.
  • In the Minutes column, select only 0 and 30 because your app will only sleep every 30 minutes.

This is how your schedule settings will look in the end. Once everything looks fine, create your cron job.

The last picture is with the normal settings

User Defined Settings

cron-job-custom-schedule

Normal Settings

cron-job-details

Congratulations! You have successfully kept your Heroku app alive.