Keep a Discord Bot Online for Free: Replit Alternatives
The bot works while you're testing it and, a while after you close the tab, it disconnects. It's not your code: it's where it's hosted. Here's why it happens and which free options really keep it online.
Why your bot goes offline
A Discord bot is a program that has to be running all the time, connected to Discord and waiting for messages. If the program stops, the bot shows as offline and doesn't reply (if it's online and still doesn't reply, that's something else: my Discord bot isn't responding).
The free tiers of platforms built for websites, like Replit or Render, put your program to sleep when nobody visits its page: on Render, after 15 minutes without visits. A bot gets no visits (it's the one connecting to Discord), so to the platform it looks “idle” and gets put to sleep. On top of that, Render's background workers, which is exactly what a bot is, have no free version.
Rather not set it up yourself? Discord bot hosting from €1.50 a month, no contract and a full refund within 72 hours. Or create a free Discord bot, no card needed.
The keep_alive trick, and why it fails
Many tutorials add a small web server to the bot (the famous keep_alive.py with Flask, or an Express server in Node.js) plus an outside service that visits it every few minutes so it doesn't fall asleep.
It works some of the time: the platform can still restart or stop it whenever it likes, the bot drops for a few seconds or minutes on every restart, and you depend on two free services at once. If yours disconnects on its own several times a day, this is almost certainly why.
Free options that really keep it online
Your computer: free and with no limits, but the bot goes offline when you switch the computer off or the connection drops. Good for writing and testing it.
A Raspberry Pi or another small computer at home: a command bot runs easily on a Raspberry Pi and uses a few watts, a few euros of electricity a year (work it out with the electricity cost calculator). It has to stay on and connected, and the bot should restart itself if it crashes (how, below).
Free machines from cloud providers, like Oracle Cloud's Always Free tier: a virtual machine of your own, but it asks for a card to sign up, you have to install and maintain the system, and Oracle can reclaim free machines it sees as idle (under 20 % CPU for 7 days), and a bot barely uses any CPU.
Railway gives a small free credit each month (1 dollar on its free plan), which isn't enough to keep a program running the whole month.
A bot host, like the NapNodes free bot (in the next section): the bot stays online with no web server or pings, and you only have to renew it once a week.
If it's on a Raspberry Pi: make it restart itself
On Raspberry Pi OS (or any Linux with systemd), create this file with “sudo nano /etc/systemd/system/mybot.service”, changing the folder, the user and the command to yours (for Python, ExecStart=/usr/bin/python3 main.py). Then run “sudo systemctl enable --now mybot”: the bot starts when the Raspberry Pi boots and comes back on its own after 5 seconds if it crashes. “journalctl -u mybot -f” shows what it prints.
[Unit]
Description=My Discord bot
After=network-online.target
Wants=network-online.target
[Service]
User=pi
WorkingDirectory=/home/pi/mybot
ExecStart=/usr/bin/node index.js
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.targetWith the NapNodes free bot
Create your account and pick the free bot
No card. It has 256 MB of memory, plenty for a command or moderation bot. There's one per person; if there are no free spots left, you join the waiting list and it's created as soon as there's room.
Remove the keep_alive
You don't need it here: the bot stays online even if nobody visits anything. You can delete the web server and the outside ping from your code.
Upload the code and pick the language
Node.js or Python, in “Settings” → “Language” (the version, in “Version & startup”). The code goes in “Files” or comes from your GitHub repository, which is also set in “Settings”; the dependencies in package.json or requirements.txt install themselves at startup. The token goes in a .env, never in a public repository.
Start it and renew it every week
With “Start” it stays online. Every 7 days you renew it with one click (“Start” or “Renew now” in the panel); we email you the day before. If you don't renew it, it stops, but it isn't deleted; only after 14 days without renewing, and with a warning first.
When to move to a plan
If you'd rather not have to remember to renew it, or your bot needs more memory (lots of servers, big caches), the Mini (512 MB) and Plus (1 GB) plans stay online with nothing to renew, and no contract (pricing). How to set it up, in the Discord bot hosting guide.
Frequently asked questions
Why does my Discord bot go offline on its own on Replit?
Because the free tier puts programs to sleep when they get no visits, and a bot gets no visits: it's the one connecting to Discord. You need somewhere that keeps it running even if nobody visits anything.
Do I need keep_alive.py for a Discord bot?
Only on platforms that put programs without visits to sleep. On your PC, on a Raspberry Pi or on a bot host you don't need it: you can remove it.
Can I keep a Discord bot online for free?
Yes: on a Raspberry Pi at home, or with the NapNodes free bot (256 MB, always online, renewed with one click every week).
Is Render any good for a free Discord bot?
Not really: Render's free offering is web services, which fall asleep after 15 minutes without visits, and background workers (which is what a bot is) have no free version.
Shall we set it up for you?
Discord bot hosting from €1.50 a month, never oversold: your RAM is yours alone. And if you'd rather start without paying, there's a free Discord bot, no card needed.
Free tool: Discord timestamp generator. Pick a date, time and time zone and copy the <t:…> so everyone on Discord sees the time in their own zone, or a countdown.
Free tool: Discord embed generator. Build an embed with a title, colour, fields and images, see it as Discord shows it and copy the discord.js, discord.py or webhook JSON code.
Keep reading
- Discord Bot Hosting: Keep Your Bot Online, Free or Paid
Keep your Discord bot online around the clock: Node.js or Python, upload your code or pull it from GitHub, where the token goes and how much RAM it needs.
- Discord Bot Not Responding (or Showing Offline): Causes and Fixes
Your Discord bot doesn't reply or shows as offline: token, Message Content Intent, permissions, error 429… Each error and its fix in discord.py and discord.js.
- Your Discord bot token: where to keep it and what to do if it leaks
Where to keep your Discord bot token so it doesn't leak (.env and .gitignore) and what to do, in order, if you pushed it to GitHub or it got stolen.