How to Run a Discord Bot 24/7: Hosting Options, PM2, systemd, and Docker in 2026
Search trends around discord bot hosting, how to host discord bot, and run node bot 24/7 usually come from the same pain point: Discord bots must stay online to respond to slash commands, buttons, and Gateway events. Laptops sleep. Free sandboxes spin down. This guide compares realistic hosting options, shows process management patterns, and explains why bot hosting discord free tiers often cost more in time than money.
What “24/7” Actually Means for Discord Bots
A Discord bot is a long-running process with a persistent Gateway WebSocket connection (plus REST calls). You need:
- A machine that stays awake.
- Automatic restart on crash or reboot.
- Enough RAM and CPU for your library (discord.js, discord.py, JDA, etc.) and any side work (databases, Lavalink, web dashboards).
“Works when I keep the terminal open” is not production hosting.
Hosting Options Overview
VPS (virtual private server)
Pros: Full control, stable IP, predictable pricing, good for music bots, databases, and sidecars. Cons: You patch the OS and manage security.
A VPS is the default recommendation for serious discord bot hosting when you want run node bot 24/7 without surprise sleep policies.
Platform-as-a-service (PaaS)
Pros: Git push deploys, managed TLS for webhooks, easy horizontal scaling for stateless web APIs. Cons: Many PaaS products are built for HTTP request cycles, not infinite WebSocket clients. Read provider terms: some disallow always-on bots or charge in ways that bite at scale.
“Free” tiers and hobby hosts
Pros: $0 upfront, fast to try. Cons: Cold starts, mandatory sleeps, ephemeral filesystems, or bans on persistent connections. For bot hosting discord free searches: treat these as prototyping only unless the provider explicitly supports long-lived processes with fair use you can live with.
Reality check: If your community depends on moderation or ticket workflows, downtime from a sleeping free tier is worse than a few euros per month on a small VPS.
Home server or Raspberry Pi
Pros: Fun, educational. Cons: Residential internet, dynamic DNS, NAT, and power outages. Fine for personal experiments, risky for public communities unless you invest in UPS and networking.
Process Management: PM2 for Node.js
PM2 keeps Node apps alive and restarts them on failure.
Typical workflow:
npm install -g pm2
cd /path/to/bot
pm2 start index.js --name discord-bot
pm2 save
pm2 startup
Why it helps: Survives SSH disconnects, logs to files, supports cluster mode for stateless HTTP services (less common for single-shard Discord bots).
Caveat: PM2 does not replace a security model. Run the bot as a non-root user, store tokens in environment variables, and restrict file permissions.
systemd Service Setup (Node or Python)
On Linux VPS deployments, systemd is the native supervisor.
Example outline for a Node bot:
- Create a dedicated user
discordbot. - Put code in
/opt/discord-bot. - Environment file
/etc/discord-bot.envwithDISCORD_TOKEN=...(mode0600). - Unit file
discord-bot.servicewithRestart=always,WorkingDirectory, andExecStart=/usr/bin/node /opt/discord-bot/index.js.
After systemctl enable --now discord-bot, reboot the server once to confirm it comes back online. That is the bar for true run node bot 24/7 reliability.
Python bots follow the same pattern with ExecStart=/path/to/venv/bin/python bot.py.
Docker Deployment
Package the bot with a Dockerfile:
- Pin base image versions.
- Copy
package.json/requirements.txt, install deps, copy source. CMDruns the bot process.- Use Docker Compose if you add Redis, Postgres, or Lavalink.
Restart policy unless-stopped gives you automatic recovery. Mount volumes only where you need persistence (SQLite file, local logs).
Docker shines when you run multiple isolated services on one VPS without dependency conflicts.
Monitoring Uptime
Minimum viable monitoring:
- Process checks: systemd status, PM2 list, or Docker health if you add a lightweight HTTP health port.
- External pings: A third-party uptime monitor hitting a small Express health endpoint (if you run one) catches “process up but Gateway dead” only partially, but still helps.
- Logs: Centralize or rotate logs so disk fills do not kill the host.
Discord’s own health pages and library logs help distinguish “my host died” from “Discord had an incident.”
Cost Comparison (Rough Mental Model)
Prices change by region and provider, but the pattern is stable:
- Free tier: $0, unpredictable uptime, possible ToS friction for bots.
- Budget VPS: Low single-digit to low double-digit euros per month for 1 to 2 GB RAM, enough for many bots plus a database.
- Mid VPS: More headroom for music stacks, sharding, or multiple bots with isolation.
Total cost of ownership includes your time debugging sleep policies and redeploying after data loss on ephemeral disks.
Why Space-Node VPS Works for Discord Bots
Space-Node offers VPS hosting suited to always-on workloads in Europe. If your players or community are EU-heavy, hosting the bot close to Discord’s Gateway regions reduces tail latency for REST calls and ancillary services you run beside the bot.
You do not need a huge plan for a typical single-shard discord bot hosting setup: start small, watch RAM during peak hours, scale the VPS when you add music nodes, caches, or web dashboards.
Security and Operations Checklist
- Tokens only in env vars or secret managers, never in Git.
- Principle of least privilege for bot OAuth scopes.
- Regular OS updates on your VPS.
- Backups if you store guild configs or economy data in SQLite.
Resource Planning for Music and Lavalink Stacks
Music bots are not the same workload as a slash-only utility bot. You may run Lavalink or similar alongside Node, which means:
- Extra JVM heap and stable file descriptors.
- Outbound bandwidth for audio streams.
- CPU for encoding and mixing paths your library uses.
If you are near RAM limits, split music infrastructure onto its own VPS so restarts on one service do not cascade.
Logging and Debugging Production Crashes
Ship logs somewhere durable:
- journald for systemd units, or PM2 log rotation.
- Optional JSON logs forwarded to a cheap log host if you operate many bots.
On crash loops, capture the first stack trace, not only the thousandth repeat. Often the root cause is a missing env var or a dependency version skew after deploy.
Sharding and Growth
When your bot approaches Discord’s sharding thresholds, one VPS may still hold all shards, but CPU and memory headroom must be planned. Horizontal scaling across machines is possible but adds coordination (Redis, shared session state if any). Most communities never need this, but growth teams should watch guild counts in monthly reviews.
Node and Python Version Hygiene
Node: Use an LTS release matched to your library’s support matrix. discord.js major versions document minimum Node versions. Running bleeding-edge Node on day zero sometimes breaks native addons.
Python: Pin python in your systemd unit or Docker image. Use virtualenvs on bare metal so pip install does not fight system packages.
Document the versions in your README so the person who fixes a 3 AM outage is not guessing.
Deploy Pipelines Without Downtime Theater
Small bots tolerate a few seconds of reconnect. Still, good habits help:
- Pull new code to a release directory, symlink
current, restart supervisor. - Health check after deploy: one synthetic slash command in a staging guild.
If you deploy five times a day, automate. If you deploy monthly, a checklist is enough.
When Two Bots Share One VPS
Multiple bots on one machine are fine until they are not. Separate directories, separate systemd units or PM2 processes, and separate env files prevent token mix-ups. If one bot hogs RAM, cgroups or simple ulimits can cap damage while you refactor.
FAQ
Can I host a Discord bot for free 24/7?
Sometimes, on providers that explicitly allow long-lived processes and do not force sleeps. For anything community-critical, expect unreliability or hidden limits. A small VPS is the pragmatic fix.
PM2 or systemd?
PM2 is convenient for Node-heavy workflows and quick iteration. systemd is native on most Linux servers and avoids an extra dependency. Both are valid on a VPS.
Do I need Docker for a simple bot?
No. Docker helps when you have multiple services or want reproducible deploys. A plain Node process under systemd is perfectly fine.
How much RAM does a Discord bot need?
Many simple bots fit in 512 MB to 1 GB comfortably. Add headroom if you run databases, image processing, or music stacks on the same machine.
What breaks “24/7” most often?
OOM kills, disk full logs, unhandled promise rejections, host suspensions on free tiers, and token leaks leading to forced resets. Harden the boring operational layers first.
Discord’s infrastructure and library APIs evolve. Keep dependencies updated and read changelogs before major upgrades.