EQVPS

How to host a Discord bot 24/7 on a VPS (systemd)

Keep a Discord bot online 24/7 on a VPS: install the runtime, put the bot token in an env file, and wrap it in a systemd service with Restart=always so it survives crashes and reboots. Copy-paste for Node and Python.

A free bot host works until the container sleeps or the service shuts down mid-event. A $3 VPS with systemd keeps the bot online for real. This is the how-to; for the fuller walkthrough and music-bot notes, see host a Discord bot on a VPS and the VPS for Discord bots use-case. No dedicated IP needed — a Discord bot only makes outbound connections, so a NAT plan (from $3/mo) is ideal.

1. Install the runtime and your bot (Node example)

apt update && apt install -y curl git
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
apt install -y nodejs
git clone https://github.com/you/your-bot.git /opt/bot
cd /opt/bot && npm ci --omit=dev

2. Keep the token in an env file

cat >/opt/bot/.env <<'EOF'
DISCORD_TOKEN=your_token_here
EOF
chmod 600 /opt/bot/.env

3. systemd service with Restart=always

# /etc/systemd/system/discordbot.service
[Unit]
Description=Discord Bot
After=network.target

[Service]
WorkingDirectory=/opt/bot
ExecStart=/usr/bin/node index.js
EnvironmentFile=/opt/bot/.env
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now discordbot
journalctl -u discordbot -f

Restart=always is what makes it 24/7 — an unhandled rejection at 3 a.m. restarts instead of leaving the bot dead. (More in create a systemd service.)

Python instead?

Same pattern — a venv and discord.py, with the unit pointing at the venv Python:

ExecStart=/opt/bot/.venv/bin/python bot.py

Notes

Nano at $3/mo, root in about a minute, no KYC, pay in crypto — cheap enough to be disposable when a bot project ends. Same pattern for Telegram bots.

FAQ

How do I keep a Discord bot online 24/7?

Put it on a VPS and wrap it in a systemd service with Restart=always, so it restarts on crash and starts on boot. Running it in a terminal or with nohup dies on disconnect or reboot; systemd keeps it alive and logs to journalctl. Copy-paste units for Node and Python are below.

Do I need a dedicated IP for a Discord bot?

No. A Discord bot dials out to Discord's gateway over a websocket — nothing connects to your server inbound. A NAT plan (from $3/mo) is a perfect, cheap fit. You'd only want a dedicated IP for a bot that also serves inbound web requests.

What's the cheapest plan that works?

Nano ($3/mo — 2 vCPU, 1 GB) runs a typical discord.js or discord.py bot, and several at once. Bots sit in tens of megabytes of RAM. A music bot is the exception — audio streaming wants a bit more CPU and bandwidth, so step up to Micro/Small.

How do I store the bot token safely?

In an environment file that only root can read (chmod 600), loaded via the systemd unit's Environment or EnvironmentFile. Never hard-code the token in the source or commit it to git — a leaked token lets anyone control your bot.

Do you ask for ID or a card?

No. Email to sign up, pay in USDC or USDT — no documents, no card. Root in about a minute.

Comments

No comments yet. Be the first.

Leave a comment

Comments are moderated before they appear.