keep-alive-ping
v1.0.0
Published
Keeps a free-tier website awake by sending automatic requests to it at any interval you set.
Maintainers
Readme
keep-alive-ping
Free hosting sites (Render, Railway, Heroku) put your site to sleep when nobody visits it. This module sends automatic requests to your site so it stays awake.
Install
npm install keep-alive-pingTwo ways to use it
1. Run it directly (no code needed)
npx keep-alive-ping <your-url> <interval-in-milliseconds>2. Use it inside your own Node app
const keepAlive = require('keep-alive-ping');
const stop = keepAlive('https://mysite.com', 5 * 60 * 1000); // url, interval in ms
// ...your own code here...
// When you want to stop, call stop()
process.on('SIGINT', () => { stop(); process.exit(0); });stop() is optional. Without it the pings keep going, which is what you want for a server that should always stay awake.
If you cloned this repo
npm install
node index.js <your-url> <interval-in-milliseconds>How to use
Open a terminal and run:
npx keep-alive-ping <your-url> <interval-in-milliseconds>Example 1 — ping my site every 5 minutes:
npx keep-alive-ping https://mysite.com 300000Example 2 — ping my site every 1 minute:
npx keep-alive-ping https://mysite.com 60000Example 3 — no interval given, it uses 5 minutes:
npx keep-alive-ping https://mysite.comTime in milliseconds:
| You want | Type this |
| --- | --- |
| every 10 seconds | 10000 |
| every 1 minute | 60000 |
| every 5 minutes | 300000 |
| every 30 minutes | 1800000 |
What you will see
2026-10-03T16:39:36.240Z 200 https://mysite.com
2026-10-03T16:44:36.301Z 200 https://mysite.comEvery line means one request was sent. 200 means your site replied correctly.
If you see FAIL, the request did not go through. The reason is printed next to it (for example, no internet, or your site took too long to reply).
To stop it
Press Ctrl + C in the terminal.
Testing it on your computer
The test-server folder has a dummy website that logs every request it receives. Use it to check that your module is working.
Terminal 1 — start the dummy site:
node test-server/server.jsYou will see it log every request:
Test server on http://localhost:4000
2026-10-03T16:48:39.894Z request received: GET /Terminal 2 — start the module:
node index.js http://localhost:4000 5000(If you installed it from npm, type npx keep-alive-ping http://localhost:4000 5000 instead.)
If terminal 1 keeps printing new lines, the module works.
Good to know
- It sends a simple GET request (the same thing a browser does when it opens a page).
- If your site needs a login or password, this will not work as it is.
- If a request takes longer than 10 seconds, it gives up and tries again on the next interval.
