How to keep a Discord bot online 24/7:
self-hosting or a bot host

A bot is online only while its program is running and connected to Discord. You can run that program on your own computer, a free platform or a bot host, and what separates them is whether it can stay on around the clock.

Updated 4 min read vProxy Cloud team

vPanel Setup wizard for a Discord bot with five steps (code source, main file, version, token, start): language Python, main file app.py, version Python 3.13, and a final step that starts the bot

Why bots go offline

  • The computer shuts down or sleeps, or someone closes the window running the program.
  • The program crashes and nobody restarts it.
  • A free platform sees no traffic and puts the program to sleep.

A server that stays on takes care of shutdowns and sleeping. A crashed program still goes offline, though, so you need to know when it stops.

Where to run the code

Running a Discord bot on your own computer, a free platform or Discord bot hosting
ComparedYour own PCFree platformBot hosting
CostElectricityFreefrom NT$29/mo
UptimeOnly while the PC is onMay sleep or queue24/7
MemoryDepends on your PCSmall, often capped512 MB to 2 GB
Outbound IPYour home IPOften shared by many usersShared with other bots, dedicated outbound IP available as an add-on
Updating codeEdit and restartDepends on the platformUpload files or push to GitHub

While a bot is still in development or testing, running it on your own computer is fine. A free platform can work for a small bot that tolerates some downtime, as long as you keep an eye on sleep rules and resource limits. Bot hosting is for bots that need to stay online 24/7, written in JavaScript, Python, Java or Go.

Token and permissions

The token is generated when you create the bot in the Developer Portal. Anyone who has it can fully control your bot, so guard it like a password.

  • Keep the token in a config file such as .env, never in the code itself.
  • Before pushing to GitHub, add .env to .gitignore, because anyone can see every file in a public repository.
  • To read the text of regular messages, turn on Message Content Intent in the Developer Portal and set the intents in your code.

Set up on a bot host

1. Choose a plan

Discord bot hosting plans
PlanMemoryCPUStorageMonthly
DCB-A 512 MB 1 core 10 GB NT$29
DCB-B 768 MB 1 core 15 GB NT$39
DCB-C 1 GB 1.5 cores 20 GB NT$49
DCB-D 2 GB 2 cores 50 GB NT$99

Hosted in the United States on AMD EPYC. Prices in New Taiwan dollars (TWD), billed every 30 days.

2. Go live with the Setup wizard

The Setup wizard in vPanel has 5 steps.

  1. Code source: put your bot's files on the server.
  2. Main file: the file to run at startup, such as index.js or app.py.
  3. Version: the runtime version, such as Python 3.13.
  4. Token: if there is no .env, the wizard creates an empty template. Open .env in Files and paste your token after DISCORD_TOKEN=. The wizard does not fill in the token for you, and it does not read a .env that already exists.
  5. Start: installs packages, then runs the main file.
The .env file opened in vPanel Files: two English comments say to keep the file private and to paste the token after the equals sign, followed by an empty DISCORD_TOKEN= line
The .env template created by the Setup wizard (demo screen).

If the console shows Improper token or a 401 error, the token is wrong. Check .env for extra spaces or quotation marks copied along with it.

3. Manage packages

A Node.js bot lists its packages in package.json, and npm install runs on every start. To add a package, enter its name and version under Packages.

4. Auto-update from GitHub

Once you link a GitHub repository and branch, the bot pulls the latest code each time it restarts. With the GitHub webhook turned on, a push to the tracked branch makes the bot pull and restart in about 10 seconds.

vPanel GitHub auto-deploy: Git repository URL, tracked branch main, auto-update on start turned on, an update and restart now button, and GitHub webhook settings
After you push to GitHub, the bot updates itself. Screenshot from vPanel (Chinese interface). The menu in the top-right corner switches vPanel to English.

5. Get notified when it crashes

As long as you didn't stop it yourself, Alerts sends a message to your Discord webhook or Telegram whenever the bot goes down. The reason for the crash shows up as an error in the console.

vPanel Alerts settings: Discord webhook URL, Telegram bot token and chat ID, with a description of crash notifications
Notification settings in Alerts. The Discord webhook URL goes in the first field.

References

FAQ

Can a Discord bot stay online 24/7 for free?
Yes, with limits. Free platforms often put apps to sleep when there is no traffic, give very little memory, or run many bots behind one shared IP. When Discord restricts a shared IP, every bot on it is affected. vProxy Cloud bot hosting offers a dedicated outbound IP as an add-on.
How much RAM does a Discord bot need?
512 MB is enough for a typical bot with commands and auto-replies. Bots written in Java use more memory at startup, so start at 768 MB. Music bots process audio in real time and do better with 2 GB.
What should I do if my token leaks?
Open the Bot page in the Discord Developer Portal and click Reset Token. The old token stops working right away. Paste the new token into .env on the server and restart the bot.
My bot receives commands but cannot read message content. Why?
It needs Message Content Intent. Enable it on the Bot page in the Developer Portal and add the matching intent in your code, and the bot will be able to read the text of regular messages.
The host is in the US. Will members in Asia notice lag?
No. Members connect to Discord, not to your host. Only the bot talks to the Discord API.

vProxy Cloud customers who are still stuck can open a support ticket in the client portal. Select the server the ticket is about and include the error from the console.

Service status

Host your Discord bot

Plans from NT$29/mo. Supports JavaScript, Python, Java and GoBilled every 30 days