Discord bot hosting on your own VPS
A Discord bot has to stay connected all the time, which is exactly what a small Linux server is good at. Here is how to choose a size, set up a discord.js or discord.py bot on Ubuntu, keep it running after crashes and reboots, and update it safely.
Where should a Discord bot run?
Most bots keep a permanent WebSocket connection to the Discord gateway. That needs a process that never sleeps, which rules out many free and request-based platforms.
| VPS | Web hosting | Serverless functions | |
|---|---|---|---|
| Always-on gateway connection | Yes, the process runs as long as you want | Built for websites answering requests, not long-running bots | No, functions stop after each request |
| Slash commands via HTTP interactions endpoint | Yes | Depends on the platform | Yes, a good fit for small HTTP-only bots |
| Voice, music, scheduled jobs, local database | Yes | Usually not | No |
| You maintain the server | Yes | No | No |
Which plan for your bot
- Developer (1 vCPU, 2 GB RAM): one or a few typical moderation, utility or ticket bots in up to a few thousand servers, plus SQLite or a small PostgreSQL.
- Production (2 vCPU, 4 GB RAM): a bot with a dashboard website, a larger database, or a music bot that runs Lavalink (a Java audio server that wants its own memory).
- Performance (4 vCPU, 8 GB RAM) and up: large bots that need sharding (Discord requires it from 2,500 servers) across several processes, or many bots on one machine.
Plans
| Plan | What you get | Price |
|---|---|---|
| Developer Compute | 1 vCPU · 2 GB RAM · 30 GB NVMe · IPv4 | €4.99/mo |
| Production Compute | 2 vCPU · 4 GB RAM · 60 GB NVMe · IPv4 | €8.99/mo |
| Performance Compute | 4 vCPU · 8 GB RAM · 120 GB NVMe · IPv4 | €14.99/mo |
| Enterprise Compute | 8 vCPU · 16 GB RAM · 240 GB NVMe · IPv4 + IPv6 | €29.99/mo |
| Sovereign Compute Ultra | 12+ vCPU · 32 GB+ RAM · 400 GB NVMe · IPv4 + IPv6 | On request |
Prices per month. Billed monthly, no long contract.
See all plansSetup walkthrough on Ubuntu 24.04
- Prepare the serverSign in over SSH, run apt update && apt upgrade -y, create a user for the bot with adduser bot, and switch to it with su - bot.
- Install the runtimeNode.js: install the current LTS (for example 22.x) from NodeSource or with nvm, and check it with node -v. discord.js v14 needs Node 18 or newer. Python: apt install python3-venv, then python3 -m venv .venv and .venv/bin/pip install discord.py.
- Upload the codegit clone your repository, or copy files with SFTP. Run npm ci --omit=dev for Node.js, or pip install -r requirements.txt inside the virtual environment for Python.
- Put the token in an env fileCreate .env with DISCORD_TOKEN=your-token, then chmod 600 .env and add .env to .gitignore. Read it in code with process.env.DISCORD_TOKEN (Node 20.6+ can load it with node --env-file=.env) or os.environ["DISCORD_TOKEN"] in Python.
- Keep it running with systemdCreate /etc/systemd/system/mybot.service with User=bot, WorkingDirectory=/home/bot/mybot, EnvironmentFile=/home/bot/mybot/.env, ExecStart=/usr/bin/node index.js (or /home/bot/mybot/.venv/bin/python bot.py), Restart=always and RestartSec=5, plus WantedBy=multi-user.target. Then systemctl daemon-reload and systemctl enable --now mybot.
- Or use pm2 for Node.jsnpm install -g pm2, pm2 start index.js --name mybot --node-args="--env-file=.env", then pm2 save and run the command printed by pm2 startup so it comes back after a reboot.
Logs, updates and security
- Logs: journalctl -u mybot -f with systemd, or pm2 logs mybot.
- Updates: git pull, reinstall dependencies, then systemctl restart mybot or pm2 restart mybot. Test bigger changes on a second test bot first.
- Firewall: a gateway bot only makes outgoing connections, so with ufw you can allow SSH and nothing else. Open 443 only if you run a dashboard or an HTTP interactions endpoint.
- If the token ever leaks, reset it in the Discord Developer Portal straight away and update the env file.
- Back up the database file or dump it regularly to somewhere off the server.
Running it on EclipsiumX
Choose a plan, pick Ubuntu 24.04 LTS (or another system from the current list), name the server and pay on checkout after creating your EclipsiumX account. You get root over SSH and a browser console in the VPS panel, which helps when you lock yourself out of SSH. The servers are in Germany, close to most EU users. Billing is monthly from €4.99, and the VPS is unmanaged: the bot and the system are yours to run.























