You built a Discord bot, it works, and your server likes it. Then you close your laptop and it goes offline. This guide explains why that happens, the three ways to keep a bot online around the clock, what to look for in a bot host, and how to move a bot you already have without breaking it.
Why Your Bot Goes Offline on a Home PC
A Discord bot is a program that stays connected to Discord. While it runs, it holds a live connection to Discord’s servers, receives messages and commands, and sends replies. The green “online” dot means that program is running and connected.
When the program stops, the bot goes offline. On a home PC, that happens more often than you’d think:
- The PC sleeps or shuts down. Closing a laptop lid or letting a desktop sleep stops the program.
- The OS restarts for updates. The bot doesn’t start again on its own unless you set that up.
- The internet drops. Most bot libraries reconnect after a short drop, but a long outage or a router restart can leave the bot stuck until you restart it.
- The bot crashes. An unhandled error ends the program, and nothing starts it again.
- You close the terminal. If you started the bot from a terminal window, closing that window stops it.
To keep a bot online 24/7, it needs to run on a machine that stays on, with something that starts it again when it stops.
Three Ways to Keep a Bot Online
| Option | Cost | Effort | Best For |
|---|---|---|---|
| Your own always-on machine | Hardware and power | Medium: you handle power, network, and restarts | Hobby bots and learning |
| A general VPS | Monthly rental | High: you manage the whole server | Developers who want full control |
| A bot host | Monthly plan | Low: you manage your code | Most bots |
1. Your Own Machine
A spare PC, an old laptop, or a Raspberry Pi can run a small bot. The machine has to stay on and connected all the time, so you’re relying on your home power and internet. You also need a process manager, such as PM2 for Node.js or a systemd service on Linux, so the bot starts again after a crash or a reboot.
This works well for learning. It’s less reliable for a bot a whole community depends on, because a power cut or a router restart takes it down until you notice.
2. A General VPS
A VPS (virtual private server) is a Linux machine you rent in a data center. It stays on, and the network is more reliable than a home connection. The tradeoff is that the whole server is yours to run: you install and update the OS and the language runtime, set up a process manager, configure the firewall, and keep it patched.
That’s a good fit if you already run Linux servers or want to host other services next to your bot. If you only want the bot online, it’s a lot of setup for one program.
3. A Bot Host
A bot host runs the machine and the runtime for you. You pick a language, give it your code, and start the bot. Updates to the OS and the server are the host’s job, and you only manage your bot.
For most bots, this is the simplest way to stay online, and it’s what WinterNode’s Discord bot hosting is built for.
What to Look for in a Bot Host
Your language and version. Check that the host runs your language and the version your code needs. WinterNode supports Node.js, Python, and Java.
Deploy from GitHub. If your code lives in a GitHub repository, deploying from it saves you from uploading files by hand after every change. On WinterNode, you connect your repository, push your changes, and restart the bot. With Auto Update on, the bot pulls your latest code every time it starts.
Automatic dependency installs. Your bot needs its libraries, like discord.js or discord.py. A host that installs them from your package.json or requirements.txt saves a step on every deploy. WinterNode installs Node.js and Python dependencies automatically and reinstalls them when you change versions.
A place to store data. Bots that track levels, settings, or moderation logs need a database. A file-based database like SQLite works for small bots. As a bot grows, a database server like MySQL is easier to back up and to share between your bot and other tools, such as a dashboard. Every WinterNode bot plan includes 3 MySQL databases.
Console access. When a bot crashes, the console output tells you why. You need to see it, live, without opening a support ticket. WinterNode gives you full console access to view logs and troubleshoot in real time.
A safe place for your token. The host should let you keep your token out of your code (see below).
Keep Your Token Out of the Code
Your bot token is the password to your bot. Anyone who has it can log in as your bot and do anything it has permission to do in every server it’s in. Never paste it into your code, and never commit it to GitHub, even in a private repository.
Instead, put it in a .env file and read it when the bot starts:
DISCORD_TOKEN=your-token-here
- Node.js: use the
dotenvpackage, or start the bot withnode --env-file=.env index.json Node.js 20.6 or newer, then readprocess.env.DISCORD_TOKEN. - Python: use the
python-dotenvpackage, callload_dotenv(), then reados.getenv("DISCORD_TOKEN"). - Java: read it with
System.getenv("DISCORD_TOKEN"), or use a library such as dotenv-java to load the.envfile.
Add .env to your .gitignore so it never ends up in your repository.
If Your Token Was Ever Exposed
If your token was ever committed to GitHub, pasted in a chat, or shown on stream, reset it. In the Discord Developer Portal, open your application, go to Bot, and choose Reset Token. The old token stops working right away, so update your .env file with the new one.
Moving an Existing Bot to a Host
If your bot already runs on your PC, moving it takes a few steps.
- Check how your bot starts. Note the entry file (for example
index.jsormain.py) and make sure every library it uses is listed inpackage.jsonorrequirements.txt. For Java, build a single.jarthat includes its libraries. - Move the token out of the code. Put it in a
.envfile as shown above, and add.envto.gitignore. If the token was ever in your code or repository, reset it now. - Push your code to GitHub. A private repository is fine. Make sure
.envand folders likenode_modulesaren’t included. - Stop the old copy. If the bot keeps running on your PC while it also runs on the host, both copies log in with the same token and receive every event, so commands run twice or fail with interaction errors.
- Set up the bot on the host. On WinterNode, pick your language and version, connect your GitHub repository, add your
.envfile, and start the bot. Our Discord bot setup article walks through each setting, including private repositories and where the.envfile goes. - Watch the console on the first start. Dependencies install on the first start, so it can take a minute. Once the bot logs in, check that it shows as online in Discord and answers a command.
From then on, you ship an update by pushing to GitHub and restarting the bot.
Reading the Console When Your Bot Crashes
When a bot crashes, the last lines in the console almost always say why. Read from the bottom up and look for the first line that names an error. These are the ones that come up most:
| What the console says | What it means | Fix |
|---|---|---|
An invalid token was provided (discord.js) or LoginFailure: Improper token has been passed (discord.py) | The token is wrong, missing, or was reset | Check the .env file and the variable name your code reads |
Used disallowed intents (discord.js) or PrivilegedIntentsRequired (discord.py) | Your code asks for an intent that isn’t turned on | Turn on the intent (such as Message Content or Server Members) under Bot in the Developer Portal |
Cannot find module (Node.js) or ModuleNotFoundError (Python) | A library isn’t installed | Add it to package.json or requirements.txt and restart |
UnsupportedClassVersionError (Java) | The .jar was built for a newer Java version | Pick a newer Java version for the bot, or build for the one it runs |
If the error points at a line in your own code, fix it locally, test it, push to GitHub, and restart the bot. Catching errors in your command handlers also helps: one bad command then logs an error instead of taking the whole bot down.
Get Your Bot Online
A bot that only runs while your PC is on will keep dropping offline. Move it somewhere that stays on, keep the token in a .env file, and use the console when something breaks.
WinterNode’s Discord bot hosting runs Node.js, Python, and Java bots, deploys from GitHub, installs your dependencies, and includes 3 MySQL databases and full console access. Host your Discord bot →
Frequently Asked Questions
A bot is a program that keeps a live connection open to Discord. When the computer running it sleeps, shuts down, restarts for updates, or loses its internet connection, the program stops or the connection drops, and the bot shows as offline until you start it again.
Run it on a machine that never turns off. You can use your own always-on machine, rent a general VPS and manage it yourself, or use a bot host that runs the bot for you. A bot host is the least work, because the host keeps the machine running and you only manage your code.
In an environment variable or a .env file that your code reads at startup, never in the code itself. Add .env to your .gitignore so it never reaches GitHub. If a token was ever committed or shared, reset it in the Discord Developer Portal and use the new one.
Node.js, Python, and Java. Node.js and Python dependencies install automatically from package.json or requirements.txt. For Java, upload or deploy a .jar that already includes its libraries.
Yes. On WinterNode, you connect your GitHub repository, then push and restart to ship updates. With Auto Update on, the bot pulls your latest code every time it starts.





Discord Bots