How to host a Discord bot 24/7
Why a bot goes offline when you close your laptop, what it needs to stay online all day, and the steps to move a Node.js or Python bot onto a server of its own.
3 min read
A Discord bot is a program that has to keep running. While it runs on your computer, it is online only as long as that computer is on, awake and connected. Close the laptop and the bot goes grey.
To keep it online all day, the bot needs to live on a machine that never sleeps.
Your options
Leave your own computer on
It works, and it costs only electricity. But the bot drops whenever your internet does, whenever Windows restarts for an update, and whenever you need the machine for something heavy.
Free hosting
Free tiers are useful for testing. Most of them stop a program that has been idle for a while, limit how many hours it can run in a month, or restart it at random. A bot that people rely on needs something steadier.
A small server of its own
A bot does not need much: a little memory, a share of a processor and somewhere to keep its files. A small hosted server gives it exactly that, around the clock, for less than most people expect.
What your bot needs
- The right runtime. Node.js for bots written with discord.js, Python for discord.py and its relatives.
- Enough memory. A small utility bot in a few servers is comfortable in 256 to 512 MB. A bot in many servers, a music bot or one with a web dashboard needs 1 GB or more.
- Its dependencies listed. Keep
package.json(Node.js) orrequirements.txt(Python) up to date, so the server installs the same libraries you use at home. - A start file. The file the server runs, such as
index.jsormain.py. - Its token kept private. Never put the bot token in code you share or upload to a public repository. Keep it in a config file or an environment value that stays on the server. If a token leaks, reset it in the Discord Developer Portal straight away.
Moving your bot onto Mavelo
- Open the Discord bot hosting plans and pick one by memory. Choose Node.js or Python when you order.
- Pay through Razorpay. The server sets itself up and we email you when it is ready.
- Open the Mavelo panel from My servers and upload your bot's files with the file manager. Leave out
node_modulesand any virtual environment folder. They are large, and the libraries are meant to be installed on the server from yourpackage.jsonorrequirements.txt. If the bot reports a missing module on its first start, write to us and we will check the start command with you. - Check the start command under Startup, so it points at your start file.
- Press Start and watch the console. When your bot prints its "logged in" line, it is online.
Keeping it healthy
- Read the console after every change. A bot that crashes on start nearly always says why in the last few lines.
- Handle errors in your code. One unhandled error can stop the whole program. Catch errors around commands so a single bad input does not take the bot down.
- Watch the memory figure. If it climbs steadily for days, the bot is holding on to something it should release. If it is simply near the limit because the bot has grown, move up a plan.
- Update with care. Upload the new files, restart, and check the console before you walk away.
If your bot plays music, the audio work is best handed to a separate Lavalink node, which keeps the bot itself light. What Lavalink is and how to connect it explains how.

