Want to run your Telegram bot 24/7 without paying for hosting? Render.com offers a free tier that's perfect for Telegram bots. This simple guide will show you exactly how to deploy your bot in just a few steps.
- Completely free for basic bots
- Super easy setup - just connect your GitHub
- No technical knowledge needed beyond the basics
Render has one special requirement: your bot must listen on a port. Most Telegram bots don't do this by default.
Add this code to your main file (index.js):
const http = require('http');
// Create a simple HTTP server
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Bot is running!');
});
// Get port from environment or use a default
const PORT = process.env.PORT || 3000;
server.listen(PORT, () => {
console.log(`HTTP server listening on port ${PORT}`);
});That's it! This creates a tiny web server that keeps Render happy.
Make sure your package.json has the right start command:
{
"scripts": {
"start": "node src/index.js" // change this to match your file path
}
}- Sign up at render.com (it's free!)
- Click New → Web Service
- Connect your GitHub or GitLab account
- Pick your bot's repository
Fill in these details:
- Name: Your bot's name (e.g., "my-awesome-bot")
- Environment: Select "Node"
- Build Command:
npm install - Start Command:
npm start - Plan: Free
- Scroll to "Environment Variables"
- Click "Add Environment Variable"
- Add
TELEGRAM_BOT_TOKENas the key - Paste your Telegram bot token as the value
- Add any other secrets your bot needs
Click "Create Web Service" and wait about 2 minutes. That's it!
If you see this error, it means you forgot Step 1. Add the HTTP server code from above to fix it.
- Visit your Render dashboard to see logs
- Remember: on the free plan, your bot will "sleep" when inactive
- It may take up to 50 seconds to "wake up" when someone messages it after a long period
Your bot is now running for free in the cloud. No complicated server setup, no monthly bills!
Happy bot building!