Skip to content
VPS hosting · Discord bots

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.

VPSWeb hostingServerless functions
Always-on gateway connectionYes, the process runs as long as you wantBuilt for websites answering requests, not long-running botsNo, functions stop after each request
Slash commands via HTTP interactions endpointYesDepends on the platformYes, a good fit for small HTTP-only bots
Voice, music, scheduled jobs, local databaseYesUsually notNo
You maintain the serverYesNoNo

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

PlanWhat you getPrice
Developer Compute1 vCPU · 2 GB RAM · 30 GB NVMe · IPv4€4.99/mo
Performance Compute4 vCPU · 8 GB RAM · 120 GB NVMe · IPv4€14.99/mo
Enterprise Compute8 vCPU · 16 GB RAM · 240 GB NVMe · IPv4 + IPv6€29.99/mo
Sovereign Compute Ultra12+ vCPU · 32 GB+ RAM · 400 GB NVMe · IPv4 + IPv6On request

Prices per month. Billed monthly, no long contract.

See all plans

Setup walkthrough on Ubuntu 24.04

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.

Frequently asked questions

Is 2 GB of RAM enough for a Discord bot?
For most bots, yes. A typical discord.js or discord.py bot uses well under 300 MB. Music bots with Lavalink, very large caches or several bots together are the usual reasons to pick 4 GB.
Do I need to open any ports?
Not for a normal gateway bot: it connects out to Discord. You only need an open port (usually 443 behind a reverse proxy) for a web dashboard or an HTTP interactions endpoint.
systemd or pm2?
Both restart the bot after crashes and reboots. systemd is built into Ubuntu and works for any language. pm2 is convenient for Node.js and adds simple log and process commands.
Can I host several bots on one VPS?
Yes. Give each bot its own folder, env file and systemd service (or pm2 process). Watch total memory with free -h and move up a plan when it gets tight.
When does my bot need sharding?
Discord requires sharding once a bot is in 2,500 servers. discord.js and discord.py both support it; at that size a plan with more vCPU and RAM makes sense.
Can I host the bot dashboard on the same server?
Yes. Run the dashboard as another service, put Nginx or Caddy in front for HTTPS, and open ports 80 and 443 in the firewall.