A GitHub Actions workflow to prevent free-tier services on popular hosting platforms from spinning down or going to sleep.
Many hosting providers offer free tiers that automatically scale down or spin down services after periods of inactivity to conserve resources:
- Vercel: Serverless functions can cold start after inactivity
- Render: Free web services spin down after 5 minutes of inactivity
- Netlify: Serverless functions can cold start
- Railway: Free tier spins down after 5 minutes
- Fly.io: Free apps scale to zero after inactivity
- Heroku: Free dynos sleep after 30 minutes of inactivity
- Glitch: Projects can sleep after inactivity
This project sends periodic HTTP requests to your services to keep them awake.
- Multiple platform support: Built-in support for Vercel, Render, Netlify, Railway, Fly.io, Heroku, Glitch, GitHub Pages, and custom services
- Configurable schedules: Set how often to ping your services
- Flexible configuration: Custom endpoints, HTTP methods, headers, and delays
- Detailed logging: Clear output showing which services responded successfully
- Minimal dependencies: Only requires the
requestslibrary
Create a new repository for this project or add it to an existing one.
The GitHub Actions workflow is already configured in .github/workflows/keep-alive.yml. It runs every 6 hours by default.
Create a JSON configuration with your services and add it as a GitHub secret:
- Go to your repository Settings > Secrets > Actions
- Click New repository secret
- Name it
SERVICE_CONFIGS - Paste your JSON configuration (see examples below)
The workflow will automatically run on the configured schedule and ping all your services.
{
"services": [
{
"type": "vercel",
"url": "https://your-app.vercel.app",
"label": "My Vercel App"
},
{
"type": "render",
"url": "https://your-app.onrender.com",
"label": "My Render Service"
},
{
"type": "netlify",
"url": "https://your-site.netlify.app",
"label": "My Netlify Site"
}
]
}{
"services": [
{
"type": "vercel",
"url": "https://api.vercel.app",
"label": "Vercel API",
"ping_path": "/api/health",
"method": "GET",
"delay_after": 2
},
{
"type": "render",
"url": "https://my-app.onrender.com",
"label": "Main Render App",
"ping_path": "/api/heartbeat",
"method": "POST",
"headers": {
"Authorization": "Bearer your-token",
"Content-Type": "application/json"
},
"data": {"action": "ping"}
},
{
"type": "custom",
"url": "https://any-service.com",
"label": "Custom Service",
"ping_path": "/api/keep-alive",
"method": "HEAD",
"headers": {
"User-Agent": "KeepServicesAlive-Bot"
}
},
{
"type": "health-check",
"health_check_url": "https://status.your-service.com/health",
"label": "Health Check Endpoint"
}
]
}| Option | Required | Default | Description |
|---|---|---|---|
type |
Yes | - | Platform type: vercel, render, netlify, railway, flyio, heroku, glitch, github-pages, custom, health-check |
url |
Yes | - | Base URL of your service |
label |
No | Auto-generated | Friendly name for logging |
ping_path |
No | / |
Path to ping (relative to url) |
method |
No | GET |
HTTP method: GET, POST, HEAD |
headers |
No | Browser-like headers | Custom HTTP headers |
data |
No | - | Request body for POST requests |
delay_after |
No | 0 | Seconds to wait after pinging this service |
health_check_url |
No | - | Full URL for health check (alternative to url + ping_path) |
| Platform | Spin-down Time | Type | Notes |
|---|---|---|---|
| Vercel | ~10-15 min | vercel |
Serverless functions |
| Render | 5 min | render |
Free web services |
| Netlify | ~10-15 min | netlify |
Serverless functions |
| Railway | 5 min | railway |
Free tier |
| Fly.io | ~5-10 min | flyio or fly.io |
Scales to zero |
| Heroku | 30 min | heroku |
Free dynos |
| Glitch | Variable | glitch |
Can sleep |
| GitHub Pages | N/A | github-pages |
For monitoring |
| Custom | - | custom |
Any HTTP endpoint |
| Health Check | - | health-check |
Specific health endpoints |
To change how often the workflow runs, edit the cron schedule in .github/workflows/keep-alive.yml:
on:
schedule:
- cron: "0 */6 * * *" # Every 6 hoursCron syntax examples:
0 * * * *- Every hour0 */2 * * *- Every 2 hours0 */30 * * *- Every 30 minutes0 0 * * *- Daily at midnight UTC
Note: GitHub Actions has schedule limits. Free repositories can run scheduled workflows at most once per hour.
You can trigger the workflow manually:
- Go to your repository's Actions tab
- Select the Keep Free Services Alive workflow
- Click Run workflow dropdown
- Click Run workflow button
You can test the script locally:
# Install dependencies
pip install requests
# Set environment variable with your config
export SERVICE_CONFIGS='{"services": [{"type": "custom", "url": "https://httpbin.org/get", "label": "Test Service"}]}'
# Run the script
python ping.py- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License