Short answer: run the bot on a small Linux VPS as a systemd service. A Discord bot opens its own connection to Discord's gateway, so it needs no domain, no certificate and no open port. A server with 1 vCPU and 1 GB RAM for $3.90 a month runs most bots; music bots and bots in thousands of servers want 2 GB or more.
Your PC can't stay on forever, and free hosts put bots to sleep or cap their hours. A VPS keeps the bot online with a fixed IP, your own files and the language version you choose.
01Which Server
| Bot | Plan | Price |
|---|---|---|
| Moderation, commands, a few servers | 1 vCPU, 1 GB RAM, 10 GB NVMe | $3.90/month |
| Music bot, a database, or several bots | 1–2 vCPU, 2 GB RAM, 20 GB NVMe | $6.50/month |
| Large bots, AI features, image work | 2 vCPU, 6 GB RAM, 40 GB NVMe | $13/month |
For voice and music, pick a location near most of your users: Amsterdam or Frankfurt for Europe, New York for the Americas, Hong Kong for Asia.
Full root SSH access · NVMe storage · DDoS protection · No setup fee
02Before You Deploy: Intents
In the Discord Developer Portal, open your application, go to Bot and switch on the privileged intents your code asks for:
- Message Content if the bot reads what people write (prefix commands like
!play) - Server Members if it reacts to joins or reads the member list
- Presence only if it really needs online status
If the code requests a privileged intent that's switched off in the portal, Discord refuses the connection (discord.py raises PrivilegedIntentsRequired). If it's on in the portal but not requested in the code, the bot connects but message text arrives empty. Slash commands don't need Message Content.
03Put the Bot on the Server
On Ubuntu 24.04 or Debian 12, logged in over SSH as root:
- 1Create a user:
adduser --disabled-password --gecos "" bot - 2Install the runtime:
apt update && apt install -y python3-venv gitfor discord.py, orapt install -y nodejs npmfor discord.js (or Node from NodeSource for a newer version). - 3Music bots only:
apt install -y ffmpeg - 4Copy your code as the bot user (
su - bot) withgit cloneorscp, and install dependencies:python3 -m venv .venv && .venv/bin/pip install -r requirements.txt, ornpm ci. - 5Store the token in
/home/bot/bot.envasDISCORD_TOKEN=..., thenchmod 600 bot.env. - 6Test it once:
set -a; . ./bot.env; .venv/bin/python bot.pyand check the bot shows online in Discord.
04Run It as a Service
Create /etc/systemd/system/discord-bot.service:
[Unit]
Description=Discord bot
After=network-online.target
Wants=network-online.target
[Service]
User=bot
WorkingDirectory=/home/bot/mybot
EnvironmentFile=/home/bot/bot.env
ExecStart=/home/bot/mybot/.venv/bin/python bot.py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.targetFor discord.js use ExecStart=/usr/bin/node index.js. Then:
systemctl daemon-reload
systemctl enable --now discord-bot
journalctl -u discord-bot -fRestart=always brings the bot back after a crash; RestartSec=10 keeps it from hammering Discord's login if something is wrong.
05Keep It Healthy
Never commit the token
If it leaks, press Reset Token in the Developer Portal; the old one stops working at once.
Don't run two copies with the same token
Both get every event and answer twice.
Watch memory
with free -h and htop. Music queues and big caches grow; move up a size if the server starts swapping.
Update dependencies
now and then: Discord changes its API, and old library versions stop working.
06Keep the Server Safe
- SSH only from your IP with the firewall on your server page, and log in with a key.
- Automatic security updates:
apt install -y unattended-upgrades. - Back up the bot's database off the server; we don't make backups for you.
From $3.90 a month for 1 vCPU, 1 GB RAM and 10 GB NVMe, which is enough for most bots.
- host discord bot
- discord bot hosting
- run discord bot 24/7
- discord bot vps
- discord.py hosting
- discord.js hosting