Skip to content

ITZ-NIHALPATEL/Render-Keep-Alive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Render Keep-Alive

Prevent your free-tier Render services from sleeping with automated, concurrent pinging and instant Telegram alerts.

GitHub stars GitHub forks GitHub issues GitHub repo size GitHub last commit License Profile Views

Python Render JSON Telegram Bot


⭐ Support the Project

Show your support by starring the repository or forking it to set up your own keep-alive service!

Deploy to Render

Fork Star


πŸ“– Table of Contents


🎯 About the Project

Free-tier hosting services like Render automatically spin down your web applications after 15 minutes of inactivity. This project solves that by deploying a lightweight Python pinger as its own Render web service β€” it continuously pings all your endpoints concurrently every 10 minutes, keeping them alive 24/7. If any service goes down, you receive an instant Telegram alert.

The pinger also pings itself via the SELF_URL environment variable, creating a self-sustaining loop that prevents its own Render service from ever spinning down.


πŸ“Έ Screenshots

Render Service Logs

Real-time logs showing concurrent pings with status codes and latency for each site.

Render Service Logs

Telegram Downtime Alert

Instant Telegram notifications with site URL, status, and UTC timestamp when a service goes down.

Telegram Downtime Alert


✨ Features

  • πŸš€ One-Click Deploy β€” Deploy directly to Render with a single button click. Just set your env vars and go.
  • ⚑ Concurrent Pinging β€” All sites are pinged at the same time using Python's ThreadPoolExecutor, not one-by-one.
  • πŸ”„ Smart Retry Logic β€” 2 automatic retries with a 5-second delay to avoid false positives from temporary network blips.
  • πŸ“± Telegram Alerts β€” Instant notification via Telegram bot when any site is confirmed down after retries.
  • ⏱️ Runs Forever β€” Pings every 10 minutes in an infinite loop. No cron jobs, no external schedulers.
  • πŸ” Self-Ping β€” Pings its own URL to prevent Render from spinning down the pinger itself.
  • 🌐 Health Endpoint β€” Built-in web server serves a JSON health check at / with latest ping results.
  • πŸ“¦ Zero Dependencies β€” Uses only Python standard library (urllib, threading, concurrent.futures). No pip install needed.
  • πŸ”§ Flexible Config β€” Provide site URLs via SITES env var (comma-separated) or sites.json file β€” or both.
  • πŸ” .env Support β€” Built-in .env file loader for local development. On Render, use environment variables directly.

πŸ› οΈ Deploy β€” Two Ways

Choose the method that works best for you:

πŸš€ Method 1: One-Click Deploy (Fastest)

The quickest way to get started β€” no forking, no file editing. Just click, configure, and deploy.

  1. Click the button below to deploy directly to Render:

    Deploy to Render

  2. Set environment variables when prompted:

    • SELF_URL β€” Will be your new service's URL (set after first deploy, then redeploy)
    • SITES β€” Comma-separated list of URLs to keep alive:
      https://your-app1.onrender.com,https://your-app2.onrender.com
      
    • TELEGRAM_TOKEN & TELEGRAM_CHAT_ID β€” (optional) for downtime alerts
  3. Done! Your pinger is live. Update SELF_URL with your service's URL and redeploy.

πŸ’‘ Tip: With this method, all your sites are managed through the SITES environment variable in the Render dashboard. No files to edit β€” ever.

🍴 Method 2: Fork & Customize

Best if you want full control over the repository and prefer managing sites via a config file.

  1. Fork the Repository by clicking the "Fork" button at the top right of this page.

  2. Edit sites.json in your forked repository β€” list the URLs you want to keep alive:

    [
      "https://your-app1.onrender.com",
      "https://your-app2.onrender.com"
    ]
  3. Create a new Web Service on Render:

    • Connect your forked GitHub repository
    • Runtime: Python
    • Build Command: echo "No build step"
    • Start Command: python Ping.py
    • Plan: Free
  4. Set Environment Variables in the Render dashboard (see Environment Variables).

πŸ’‘ Tip: You can also set the SITES env var alongside sites.json β€” both sources are merged automatically (duplicates removed).


πŸ”” Telegram Notifications Setup

To receive downtime alerts via Telegram:

  1. Create a bot with @BotFather on Telegram and copy the Bot Token.
  2. Get your Chat ID from @userinfobot or similar.
  3. Add both values as environment variables on Render (see below).

Alerts include:

  • Site URL
  • Status (DOWN / Timeout)
  • UTC Timestamp

πŸ”‘ Environment Variables

Set these in the Render Dashboard β†’ your service β†’ Environment:

Variable Required Description
SELF_URL Yes Your Render service's own URL (e.g. https://render-keep-alive-xxxx.onrender.com). Enables self-ping to stay alive.
SITES Yes* Comma-separated URLs to keep alive (e.g. https://app1.onrender.com,https://app2.onrender.com). Required for one-click deploy.
TELEGRAM_TOKEN Optional Telegram bot token from @BotFather.
TELEGRAM_CHAT_ID Optional Chat ID where alerts are sent.
PORT Auto Render sets this automatically. No need to configure.

* SITES is required if you're using one-click deploy. If you forked the repo and added URLs to sites.json, then SITES is optional.

Tip: For local development, create a .env file in the project root. The script loads it automatically.


πŸš€ Usage

Once deployed and configured, the service runs fully autonomously:

  • Automatic β€” Pings all sites from SITES env var and/or sites.json every 10 minutes, forever.

  • Self-sustaining β€” The SELF_URL self-ping keeps the pinger itself from sleeping on Render's free tier.

  • Add or Remove Sites β€” Update the SITES env var in Render dashboard (one-click deploy) or edit sites.json and push (fork deploy).

  • Health Check β€” Visit your service URL in a browser to see a live JSON report:

    {
      "status": "alive",
      "timestamp": "1970-01-01 00:00:00 UTC",
      "cycle": 42,
      "total_sites": 3,
      "up": 3,
      "down": 0,
      "results": [
        { "url": "https://your-app1.onrender.com", "status": "up", "code": 200, "latency_ms": 285.3 },
        { "url": "https://your-app2.onrender.com", "status": "up", "code": 200, "latency_ms": 312.7 }
      ]
    }

βš™οΈ How It Works

  1. Startup β€” Ping.py starts a web server on the port Render provides and spawns a background pinger thread.
  2. Load Sites β€” Merges URLs from the SITES env var and sites.json file (duplicates removed), then appends SELF_URL (if set).
  3. Concurrent Ping β€” Every 10 minutes, all sites are pinged simultaneously using ThreadPoolExecutor. Each request uses a GET method with a 10-second timeout.
  4. Retry on Failure β€” If a site fails, it retries up to 2 more times with a 5-second delay between attempts.
  5. Alert β€” If all retries fail, a Telegram alert is sent with the site URL, status, and timestamp.
  6. Self-Ping β€” The pinger's own URL is included in the ping list, creating an inbound request that resets Render's 15-minute inactivity timer.
  7. Health Endpoint β€” The web server responds to any incoming request with a JSON report of the latest ping cycle results.

πŸ“‚ Project Structure

Render-Keep-Alive/
β”œβ”€β”€ Ping.py              # Main script β€” web server + background pinger
β”œβ”€β”€ render.yaml          # Render Blueprint β€” enables one-click deploy
β”œβ”€β”€ sites.json           # List of URLs to keep alive (fork-based deploy)
β”œβ”€β”€ .env.example         # Example environment variables
β”œβ”€β”€ Screenshots/         # README screenshots
β”‚   β”œβ”€β”€ Logs.png
β”‚   └── TelegramNotification.png
β”œβ”€β”€ LICENSE              # MIT License
└── README.md            # This file

🀝 Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

Distributed under the MIT License. See LICENSE for more information.

About

πŸš€ Keep your Render services awake 24/7. Simple heartbeat script to bypass the free-tier sleep mode and eliminate cold starts.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages