Do you need a VPS for a Discord bot?

For most bots, no. A Discord bot is a light process that only needs to stay running. A VPS pays off when you want full control of the server and are willing to administer it.

Updated 5 min read

Learning objectives

After reading this article you will be able to:

  • Understand what a Discord bot actually needs from a server
  • Know what a VPS gives you and what it leaves to you
  • Choose between a VPS and a hosting platform for your bot
On this page

"Do I need a VPS for my bot?" is one of the first questions once you move a bot off your home computer. To decide, compare the little a bot needs from a server with the work a VPS brings along.

VPSyou maintainPlatformyou sendSupervisor (systemd)Node.jsFirewall and SSHOperating systemBot codeEnvironment variablesSystem and runtimereadyBot onlineGateway connection
The bot is the same on both paths; the difference is how many layers are yours to maintain.

What does a Discord bot need from a server?#

Very little. A bot is an ordinary Node.js, Python or similar process that opens one long-lived WebSocket connection to the Discord Gateway and receives events. There is no web server, no open port and no static IP: the connection is outbound.

What it actually needs:

  • a process that stays running all the time and comes back on its own after a crash;
  • enough RAM for the runtime and the library cache (see how much RAM a bot uses);
  • a stable network connection to keep the heartbeat going. If the bot does not receive the heartbeat ACK, the connection is considered zombied and must be closed and reconnected;
  • a safe place for the token, in an environment variable.

None of this needs root access, a custom kernel or a sophisticated architecture. That is why a VPS is an option, not a requirement.

What does a VPS give you?#

A VPS is a virtual machine with root access over SSH. You get CPU, RAM, disk and an operating system, and you can install anything. If you want to learn server administration, or run the bot next to other services, it is a good fit.

It is also cheap. The smallest plans from international providers, with 512 MB to 1 GB of RAM and 1 vCPU, usually cost a few dollars a month; check current prices on the provider's pricing page, such as DigitalOcean's Droplet pricing.

What does a VPS leave to you?#

The machine's price is the small part. The rest is work:

  1. Install the runtime in the version your library requires.
  2. Keep the process alive. Without a supervisor, the bot dies at the first error or reboot.
  3. Update the system. On Ubuntu Server, unattended-upgrades is preinstalled and applies security updates on its own, but only for the system. Your application and its dependencies remain yours.
  4. Secure access: SSH keys instead of passwords, a firewall, an unprivileged user.
  5. Deploy every change: copy files, install dependencies, restart.
  6. Monitor: read logs and notice when the bot is down.

A minimal systemd supervisor, at /etc/systemd/system/bot.service:

ini
[Unit]
Description=Discord bot
After=network-online.target
Wants=network-online.target

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

[Install]
WantedBy=multi-user.target

Then sudo systemctl enable --now bot starts the bot and brings it back after a crash or reboot. The .env file holds DISCORD_TOKEN=... and should be readable only by the bot user (chmod 600). Logs show up with journalctl -u bot -f.

That is only the starting point: the firewall, updates and deploys are still your job.

VPS or hosting platform for a bot?#

Criterion VPS Hosting platform
System access Full root Inside the container
Keeping the bot alive You configure it (systemd, PM2) Depends on the platform
System updates You The platform
Deploy Manual or your own script Upload, CLI or Git
Time to first deploy Hours Minutes
Several services on one machine Yes, freely Each app runs isolated
Software outside common runtimes Runs Limited

For a broader comparison, see VPS, cloud or hosting platform.

When is a VPS worth it for a bot?#

  • You want to learn to administer a Linux server.
  • The bot depends on specific system software or unusual network setup.
  • You already have a VPS running other services and the bot fits on it.
  • You need full control of the environment.

If you pick a VPS, count maintenance as part of the cost. A bot down because of an outdated server or a missing supervisor costs more than the price difference.

When is a VPS overkill?#

Almost any time the bot is "just a bot": a few servers, a standard library, no special system software. Then you want an always-on process, and a hosting platform gives you that without turning you into a server administrator. See also how much it costs to host a bot and how to keep a bot online 24/7.

One limit to keep in mind: at 2,500 servers sharding becomes mandatory, and the bot opens several Gateway connections (shards), often split across processes. That holds on any host and is a reason to plan RAM with headroom, not to buy a VPS early.

How to do this on Square Cloud#

Square Cloud takes the hosting platform path, on a self-service model: you deploy and control the application, with no server to administer. The bot runs in an isolated, always-on container with no sleep mode, and automatic restart (on by default for dashboard deploys) brings it back when the process exits with an error.

For Discord bots, it supports discord.js, discord.py, JDA, Discord.Net or any Gateway library, with sharding and voice. You deploy by ZIP upload in the dashboard, the CLI, GitHub (a push triggers the deploy) or the VS Code extension. The squarecloud.app configuration file is optional: the dashboard generates it on deploy, with runtime, memory and main file, or you write it yourself at the root of the project. The token goes in environment variables, which apply on the next restart, with no rebuild.

The plan's RAM is a pool shared across your applications, with a minimum of 256 MB per background application, such as a bot. Hobby costs R$12.49 per month (1 GB of RAM), paid by Pix or card, with no lock-in. The other hosting features are listed in Square Cloud features.

Deploy

Push from GitHub, the CLI or a ZIP and go live in seconds

Learn more

FAQs

What is the minimum VPS size for a Discord bot?

A small Node.js or Python bot usually fits in 512 MB to 1 GB of RAM, operating system included. Bots in many servers, with large caches or voice, need more. Measure real usage before you buy.

Do I need a VPS to keep my bot online 24/7?

No. You need any machine that stays on and keeps the process alive. That can be a VPS or a hosting platform. Your personal computer does not qualify, because it shuts down, sleeps and changes networks.

Does a Discord bot need a static IP or open ports?

No. The bot opens an outbound connection to the Discord Gateway, so nothing connects in. You only need open ports if you also serve a web dashboard or an API.

When does a Discord bot need sharding?

At 2,500 servers. Each shard supports at most 2,500 guilds, and bots at that size must shard. Below that, a single process is enough.

Next articleApp keeps restarting: out-of-memory (OOM) errors explainedAn app that restarts for no clear reason is often hitting its memory limit. Learn to spot OOM kills in Node.js, Python and Java, find the cause and fix it.

More in Deploy

See all 33 articles