Guide

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

CauseWhat you seeFix
The PC went to sleep or restarted for an updateOffline for hours, no errorPower settings, and start the bot with Windows
An unhandled error crashed the processConsole window closed or shows a tracebackAuto-restart, plus fix the error from the log
Internet droppedBot goes offline briefly, then usually comes backdiscord.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 loginGenerate a new token in the Developer Portal. Restarting won't help
Too many logins in a row429 errors or a temporary block at loginWait 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:

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.