How to keep a Discord bot online on your own PC
Most "keep your bot online 24/7" guides end with "buy our hosting". If your PC is on most of the time anyway, you don't need it. Here's why self-hosted bots go offline, how to bring them back automatically without getting rate-limited, and how to hear about it when one dies. Current as of October 2026.
Why your bot goes offline
| Cause | What you see | Fix |
|---|---|---|
| The PC went to sleep or restarted for an update | Offline for hours, no error | Power settings, and start the bot with Windows |
| An unhandled error crashed the process | Console window closed or shows a traceback | Auto-restart, plus fix the error from the log |
| Internet dropped | Bot goes offline briefly, then usually comes back | discord.py and discord.js reconnect on their own, so nothing to do unless the process exits |
| Token was reset or leaked | "Improper token" or 401 at login | Generate a new token in the Developer Portal. Restarting won't help |
| Too many logins in a row | 429 errors or a temporary block at login | Wait longer between restarts (see below) |
Step 1: keep Windows awake
Settings → System → Power: set "When plugged in, put my device to sleep after" to Never. The screen can still turn off. In Windows Update → Advanced options, set active hours so update restarts happen when you're around.
Step 2: restart it automatically, slowly
A restart loop that logs back in instantly, over and over, is how bots get temporarily blocked by Discord's rate limits. Wait longer after each crash. Save this as run-bot.bat next to your bot:
@echo off cd /d "%~dp0" set WAIT=5 :loop python bot.py echo Bot stopped. Restarting in %WAIT% seconds... timeout /t %WAIT% /nobreak >nul set /a WAIT=WAIT*2 if %WAIT% GTR 300 set WAIT=300 goto loop
For discord.js, replace the python line with node index.js. The wait doubles after each crash, up to 5 minutes.
To start it with Windows, press Win+R, type shell:startup, and put a shortcut to run-bot.bat in that folder. For more control (restart on failure, run before log-in), use Task Scheduler or NSSM as in our guide to keeping a Python bot running 24/7.
Step 3: get told when it crashes
Your bot can't tell you it's offline, but a webhook can, because it doesn't need the bot to be running. In a private channel, go to Edit Channel → Integrations → Webhooks → New Webhook, and copy its URL. Then add this line to the loop, right after the bot exits:
curl -s -H "Content-Type: application/json" -d "{\"content\":\"My bot stopped, restarting\"}" https://discord.com/api/webhooks/...
Prefer a phone notification? Use the free ntfy app instead: curl -s -d "My bot stopped" ntfy.sh/your-secret-topic.
The one-window way: Helmdeck
If you run more than one bot, the batch files pile up. Helmdeck handles all of the above per bot, from one window:
- Restart if it stops. Helmdeck waits 2, 4, 8 seconds and longer between attempts (up to a minute), so you don't hammer Discord's login. A bot that crashes 5 times in 10 minutes is left stopped, and its tile shows the problem.
- Start with your PC, or only run between set hours.
- Alerts to a Discord webhook or your phone when a bot crashes, finishes, or needs you.
- Works without Node installed. Use
{node} index.jsas the start command, and Helmdeck runs it with its own built-in Node. - A live number on the tile, like commands answered today:
const { report } = require('./helmdeck-status');
report('running', { stat: `${count} replies today` });
Helmdeck is free for 3 builds. Restarts, schedules and alerts are part of Pro ($39 once).
When paid hosting is the better choice
If your PC is a laptop you carry around, or it's off at night, a small VPS or a bot host (a few dollars a month) will beat any local setup. Running on your own PC makes sense when the machine is on anyway, or when the bot uses things that only live there, like a local AI model through Ollama.
Keep every bot online from one window
Free for 3 builds on Windows, Mac and Linux. No account needed.