Skip to content
Aule-LabsPublic

About

Keep free-tier Render services awake by pinging any .onrender.com URL every 10 minutes.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

keepalive-render

Keep a free-tier Render service awake by pinging any *.onrender.com URL every 10 minutes.

Render spins free web services down after ~15 minutes without traffic, and the next visitor waits 50+ seconds for a cold start. One request every 10 minutes is enough to keep the instance warm.

Quick start

npx keepalive-render

It asks one question, then gets out of your way:

Render app URL: myapp.onrender.com

Running in the background.

To watch it:  tail -f ~/.keepalive-render/myapp.onrender.com.log

That is the whole workflow. The monitor runs detached, so the terminal is free and the pings continue after you close it.

Requires Node.js 18 or newer. No dependencies.

Usage

keepalive-render [your-app] [options]

The app can be given in any of these forms — https is assumed:

keepalive-render                      # asks for the URL
keepalive-render myapp
keepalive-render myapp.onrender.com
keepalive-render https://myapp.onrender.com

Options

Flag Default Description
-i, --every <time> 10m Time between pings. Accepts 90s, 1h, 500ms, or a bare number of minutes.
-t, --timeout <time> 30s Per-request timeout.
-p, --path <path> the URL's own path Path to request, e.g. /health.
-f, --foreground off Watch pings live in the terminal instead of detaching.
-b, --background on Run detached (the default; the flag is there if you want to be explicit).
--once off Ping once and exit: 0 on success, 1 on failure.
-q, --quiet off Only print failures.
-v, --version Print the version.
-h, --help Print help.

Examples

keepalive-render myapp --every 5m --path /health
keepalive-render myapp --foreground          # watch it, Ctrl+C to stop
keepalive-render myapp --once --quiet && echo awake

Watching the pings

Add --foreground to hold the terminal and see every request:

keepalive-render myapp --foreground
Keeping myapp.onrender.com awake every 10m · Ctrl+C to stop

16:04:48  ✓ 200  120ms
16:14:49  ✓ 200  35ms
16:24:51  ✗ 503  1.2s
16:34:53  ✓ 200  98ms  back up

Failures never stop the loop — a deploy or cold start is just a red line. Ctrl+C stops it.

Background mode

Detached is the default. Everything it prints goes to a log, and a pidfile sits next to it:

~/.keepalive-render/myapp.onrender.com.log
~/.keepalive-render/myapp.onrender.com.pid
tail -f ~/.keepalive-render/myapp.onrender.com.log   # watch it
kill $(cat ~/.keepalive-render/myapp.onrender.com.pid)   # stop it

Starting the same app twice is safe — the second run reports the PID that is already running instead of starting another monitor.

Across reboots

Background mode survives closing the terminal, not a reboot. To bring it back automatically:

# pm2
npm install -g pm2
pm2 start keepalive-render --name keepalive-myapp -- myapp.onrender.com --foreground
pm2 save && pm2 startup
# systemd (Linux): /etc/systemd/system/keepalive-myapp.service
[Unit]
Description=keepalive-render
After=network-online.target

[Service]
ExecStart=/usr/bin/npx keepalive-render myapp.onrender.com --foreground
Restart=always

[Install]
WantedBy=multi-user.target

If you would rather not run a process at all, point a free uptime pinger (UptimeRobot, cron-job.org, a GitHub Actions schedule) at the same URL every 10 minutes.

Notes

  • A ping is a normal GET with a keepalive-render user agent; the response body is drained so the connection closes cleanly.
  • Render's free tier includes 750 instance hours per month. Keeping one service awake around the clock uses most of that, which is the intended trade.
  • This keeps a service warm; it does not stop Render from redeploying, sleeping on its own schedule, or failing health checks. Render's terms and free-tier behaviour are Render's to change.

Publishing to npm

npm login                       # once, as the account that owns the name
npm view keepalive-render       # confirm the name is still free
npm publish --access public

Bump the version in package.json (npm version patch) and run npm publish again for each release. To publish under a scope instead, rename the package to @aule-labs/keepalive-render and keep --access public (scoped packages are private by default).

License

MIT © Aule Labs

About

Keep free-tier Render services awake by pinging any .onrender.com URL every 10 minutes.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages