Cloud VPS

How to Run a Discord Bot 24/7 on a VPS, Step by Step

Updated 2026-07-07~8 min read

Writing a Discord bot and running it on your own machine is fun, right up until you shut the computer down for the night and the bot goes offline with it, leaving your server waiting for commands that never come. This is the classic problem everyone hits when they start building Discord bots.

The fix that real bot developers use is to move the bot onto a VPS that stays on 24 hours a day, so you no longer have to leave your home PC running, wasting power and risking dropped connections. This article explains why a VPS is perfect for the job, with steps to install a Node.js or Python bot on a Linux VPS using pm2 so it stays online all the time, and even restarts itself automatically after the VPS reboots.

Why a home PC cannot run a Discord bot 24/7

A Discord bot has to be online at all times to receive commands and respond to events in your server. The moment the process stops, the bot shows as offline and does nothing at all. A home PC is a poor fit because you do not leave it on around the clock, and even if you do, it still has several weak points.

Think about a bot that sends member alerts, queues music, tracks stats, or runs a leveling system in a server that people use all day. If the bot keeps dropping, it loses all credibility. A VPS solves every weak point of running on a home PC.

  • Shut down or restart = the bot goes offline instantly and you have to start it again every time
  • A dropped home connection or power cut takes the bot down too, with no backup
  • Leaving a PC on 24/7 wastes power, overheats the machine, and shortens its lifespan
  • Home IPs change often and are unstable, unsuitable for tasks that must stay online continuously
  • You have to keep the PC running, which makes it awkward to use for anything else
💡 A good Discord bot needs to be "reliably online" more than it needs to be "powerful" — a small VPS that stays on all the time beats a high-spec PC that gets switched on and off.

How a VPS helps you run a Discord bot

A VPS (Virtual Private Server) is a virtual server that stays on inside a datacenter 24 hours a day, with backup power and high-speed networking far more stable than a home connection. You get full control of the machine (Full Root Access), so you can install Node.js, Python, or anything else you like.

Once your bot lives on a VPS, it stays online even when you switch off your home PC, because the bot no longer runs on your machine. You just SSH in to manage it when needed and let the VPS handle the rest.

  • On 24/7 in a datacenter with backup power and networking, 99.9% uptime
  • Full Root Access to install Node.js/Python/any library you want
  • Choose your OS, both Linux (the most popular for bots) and Windows
  • A stable IP that does not change as often as a home connection
  • Switch off your home PC and the bot stays online, saving power at home
  • Manage it over SSH from anywhere, updating or restarting the bot on the go
💡 Plusweb Cloud VPS uses KVM + SSD and provisions automatically within minutes, ideal for running a bot that has to stay online continuously.

How much VPS spec does a Discord bot need

The good news is that most Discord bots use very few resources, especially bots that just respond to general commands. You do not need to buy a high-spec VPS. Start with the smallest package, which is usually enough, and upgrade later when your bot gets more complex or lives in a large server with thousands of members.

Recommended specSuits which kind of botNotes
1 vCPU / 1 GB RAMGeneral command bots, leveling bots, alert botsEnough for most bots
1 vCPU / 2 GB RAMMusic bots on 1–2 servers, bots with a small databaseExtra RAM for audio streaming
2 vCPU / 2–4 GB RAMMusic bots on many servers, several bots on one machineRuns multiple bots at once
2+ vCPU / 4+ GB RAMBots in large servers, heavy processing/AI botsHandles high load and heavy work
💡 A music bot that streams audio uses more RAM and bandwidth than a bot that just replies to messages, so leave extra spec headroom if you run a music bot on several servers.

Steps to run a Discord bot on a Linux VPS (Node.js / Python)

Follow along step by step, starting from zero

Suppose you have finished writing your bot locally and the code is in GitHub or ready to upload. The steps below are a guide to getting the bot online for real on a Linux VPS (for example, Ubuntu).

  1. 1Order the VPS, then SSH in with ssh root@your-ip
  2. 2Update the system with apt update && apt upgrade first
  3. 3Install the runtime: for a Node.js bot install Node.js + npm / for a Python bot install python3 + pip
  4. 4Pull the bot code onto the machine, e.g. git clone from GitHub or upload via SFTP
  5. 5Install dependencies: Node uses npm install / Python uses pip install -r requirements.txt
  6. 6Set the Bot Token in a .env file or config (never hardcode the token directly in the code)
  7. 7Run the bot once to check that it comes online and responds to commands
  8. 8Install a process manager to keep the bot running (see the next section)
💡 Always keep your Bot Token secret. If it leaks, reset the token immediately from the Discord Developer Portal.

Keep the bot running with pm2 (it survives closing SSH)

If you run the bot with a plain command and then close the SSH window, the bot stops instantly because the process is tied to that session. The fix is a process manager like pm2 (for Node.js, and it works with Python scripts too), which runs the bot in the background and restarts it automatically if it crashes or the VPS reboots.

pm2 is the most popular tool for this, easy to install and use, and great for beginners. Another popular option is a systemd service, which already ships with Linux and suits long-term, professional-grade deployments.

  1. 1Install pm2 with npm install -g pm2
  2. 2Start the bot with pm2 start index.js --name mybot (Python uses pm2 start bot.py --interpreter python3)
  3. 3Check the bot status with pm2 status and view logs with pm2 logs
  4. 4Run pm2 startup then pm2 save so the bot starts itself automatically every time the VPS reboots
  5. 5Update the bot: git pull then pm2 restart mybot
💡 After pm2 startup + save, the bot comes back online by itself even if the VPS restarts, so you never have to start it manually again.

Linux or Windows: which is better for a Discord bot

For a Discord bot, Linux is the main recommendation because it uses fewer resources (no GUI weighing it down), so even a small VPS runs it smoothly. Tools like Node.js, Python, and pm2 are designed to work best on Linux, and most tutorials and examples out there are Linux-based.

You can choose Windows if you are more comfortable with it, or if your bot depends on a program or library that only runs on Windows. But Windows uses more RAM, so you need a higher spec. At Plusweb you can pick whichever OS suits you.

PointLinuxWindows
Resource usageLow, runs on small specsHigher, needs extra RAM
SuitsGeneral Node/Python botsBots that rely on Windows programs
Tools (pm2/systemd)Fully supportedUsable but configured differently
Popularity for botsHighest, plenty of examplesLess common
ConnectionSSHRemote Desktop (RDP)
💡 If you have no specific reason to need Windows, Linux is cheaper and smoother for a Discord bot.

Summary: move your Discord bot to a VPS for 24/7 uptime

Running a Discord bot on your home PC is fine only for development and testing, but when it comes to real use, the bot has to stay online all the time. A VPS is the best answer because it is on 24/7 in a datacenter with 99.9% uptime, gives you Full Root Access, and lets you pick your OS, all without leaving a PC running and wasting power.

Start with a small VPS spec that is enough for most bots, install Node.js or Python, then use pm2 to keep the bot running and self-restarting after reboots. With that, your bot stays reliably online, ready to serve your server members at all times.

Get your Discord bot online 24/7 with Plusweb Cloud VPS

From ฿150/month · Full Root Access · KVM · SSD · 99.9% uptime · Choose Linux or Windows · Auto-provisioned within minutes — switch off your home PC and the bot stays online

Frequently Asked Questions

What VPS spec do I need to run a Discord bot?

A typical Discord bot uses very few resources. Starting at 1 vCPU / 1 GB RAM is enough for command bots, leveling bots, or alert bots. For a music bot that streams audio on several servers, or a heavy-processing bot, step up to 2 vCPU / 2–4 GB RAM.

Why not just run the Discord bot on my home PC?

Because the bot goes offline the moment you shut down, lose your connection, or hit a power cut, and leaving a PC on 24/7 wastes power and overheats the machine. A VPS stays on in a datacenter with backup power and networking, so it is far better suited to a bot that must stay online continuously.

How do I stop the bot from dying when I close the SSH window?

Use a process manager like pm2. Run pm2 start to launch the bot in the background, then pm2 startup + pm2 save so it starts itself automatically every time the VPS reboots. The bot stays online even after you close SSH. A systemd service works too.

Should a Discord bot use Linux or Windows?

Linux is recommended because it uses fewer resources, runs on small specs, and tools like Node.js, Python, and pm2 fully support it. Choose Windows only when your bot depends on a program that runs only on Windows. At Plusweb you can pick either OS.

Can I run multiple Discord bots on a single VPS?

Yes. pm2 supports running multiple processes on one machine. Give them separate names (--name) and manage each one individually. Just make sure the VPS spec matches the number of bots and the total load. Starting at 2 vCPU / 2–4 GB RAM comfortably runs several bots.