Skip to content

AS213941 · Peering-20% on all VPS with code NVH20 · Delivered in 60 seconds

Linux VPSFrom 2,49 €/monthWindows VPSFrom 3,49 €/monthFiveM serverFrom 0,99 €/monthMinecraft serverFrom 1,99 €/month
VPS & Cloud

Ranges

Linux NVMe VPSRoot access, Debian, Ubuntu, Alma…Windows RDP VPSRemote desktop, licence includedDedicated serversIntel Xeon Gold, exclusive resourcesPterodactyl VPSGame panel preinstalled

Network and hosting

Anti-DDoSWeb hostingColocationIP transitVPN

Professionals

Reseller VPSReseller programme
Solutions

Bots and automation

AI agents VPSA server for your coding assistants and autonomous agentsOllama VPSYour private AI without a GPU, data in FranceTelegram bot VPSPython or Node.js, always reachableDiscord bot VPSMusic, moderation, tickets: no downtimen8n VPSWorkflows with no execution limitVPN VPSAn encrypted tunnel exiting in FranceWeb scraping VPSScheduled data collection, dedicated IP

Trading

Forex VPSYour robots manage positions overnightMetaTrader 4 VPSSeveral MT4 terminals on one machineMetaTrader 5 VPSForex, indices and stocks in MT5NinjaTrader VPSFutures and NinjaScript strategiesProp firm VPSChallenges and funded accounts, terminal always onlineAfrica trading VPSMetaTrader in Paris, from North or West AfricaRDP VPSWindows remote desktop, always onTrading bot VPSOpen-source crypto bots, protected API keys

Windows desktop

Windows 10 VPSFor software that requires Windows 10Windows 11 VPSA modern Windows desktop, reachable anywhereSEO VPSLarge-site crawls without tying up your PCStreaming VPSAn OBS studio streaming from the data centreWordPress VPSFast websites on NVMe disks
Marketplace

AI

OllamaLocal language models, with no external APIOpen WebUIA chat interface for your Ollama modelsAnythingLLMA private AI assistant for your documentsLangflowVisual editor for agents, RAG flows and AI APIsFlowiseBuild AI agents and chatbots visuallyQdrantVector database for RAG and semantic search

Trading

MetaTrader 5Official MT5 terminal, ready for your EAsMetaTrader 4Official MT4 terminal, ready for your EAsForex VPS pack (MT4 + MT5)MT4 and MT5 together, on a VPS tuned for tradingNinjaTrader 8NinjaTrader 8 with its prerequisitesFreqtradeOpen-source crypto trading bot, in simulation modeInteractive Brokers TWS / IB GatewayTWS or IB Gateway, official stable version

Bots and agents

Claude CodeAnthropic's coding agent, in your terminalCodex CLIOpenAI's command-line coding agentTelegram botYour Telegram bot, with automatic restartDiscord botYour Discord bot, with automatic restartOpenClawOpen-source personal AI assistant, active 24/7Hermes AgentAutonomous open-source AI agent

Deployment and automation

DockerThe container engine and Docker Composen8nYour automations, with no execution limitPortainerManage your Docker containers from your browserCoolifyDeploy your applications from Git, on your own serverUptime KumaMonitor your sites and servers, with alerts

Websites and databases

WordPressThe most widely used CMS, on a fast Nginx stackApache + PHP + MySQLApache, PHP and MariaDB, ready for your sitesMySQL (MariaDB)MySQL-compatible database serverPleskPlesk hosting panel, with your own licenceNextcloudYour own cloud for files, calendar and contacts

Network and security

WireGuardYour encrypted VPN, preinstalled as a paid optionVaultwardenA self-hosted password manager

Game servers

FiveMFiveM server with txAdmin and MariaDB, ready to useMinecraftTurnkey Minecraft Java server, plugins and mods includedRustRust server with automatic updates and Oxide or CarbonCounter-Strike 2Dedicated Counter-Strike 2 server, installed for youPalworldDedicated Palworld server, installed for youValheimDedicated Valheim server, installed for you
Gaming

Game servers

FiveM servertxAdmin, ESX, QBCoreMinecraft serverJava, Bedrock, modpacksRust serverOxide, Carbon, wipesNova-Life serverNova-Life: Amboise RP

Protection and tools

FiveM Anti-DDoSFree tools
Resources

Learn

DocumentationBlog

Assistance

ContactSLA commitment
View plans Client area Peering · AS213941

Bots · Tutorial · 8 min

How to host a Discord bot 24/7 on a VPS

By the NVHCloud team · 5 Nov 2026 · 8 min read

A Discord bot running on your computer disconnects as soon as you switch it off, and your members see its status turn grey. On a VPS, it stays connected day and night, restarts by itself after an error and no longer depends on your home connection. This guide goes from creating the bot to running it permanently, in Python with discord.py, with the discord.js equivalent.

💡 To go faster, the Discord bot can be preinstalled (Python, Node.js or Bun): when you order, provide your token and your code from Git or an archive. Dependencies, automatic restarts and logs are handled for you. See Preinstalled Discord bot.

1. Create the bot in the Developer Portal

  1. Open the Discord Developer Portal and create an application.
  2. In the Bot tab, generate the token ("Reset Token") and copy it. It will not be shown again: treat it like a password.
  3. Still in Bot, only enable privileged intents if you need them. Message Content is only needed to read message text; a slash-command bot does not need it.
  4. In OAuth2, generate an invite link with the bot and applications.commands scopes and only the permissions you need. Open it to add the bot to your server.

2. Prepare the VPS

On a Debian or Ubuntu VPS, logged in as root, install Python and create a dedicated user: the bot should never run as root.

apt update && apt install -y python3 python3-venv
adduser --disabled-password --gecos "" bot
su - bot
mkdir mybot && cd mybot
python3 -m venv venv
venv/bin/pip install discord.py

3. Your first bot

Create bot.py. This bot answers the /ping slash command:

import os
import discord
from discord import app_commands
intents = discord.Intents.default()
client = discord.Client(intents=intents)
tree = app_commands.CommandTree(client)
@tree.command(name="ping", description="Check that the bot responds")
async def ping(interaction: discord.Interaction):
    await interaction.response.send_message("pong")
@client.event
async def on_ready():
    await tree.sync()
    print(f"Logged in as {client.user}")
client.run(os.environ["DISCORD_TOKEN"])

Test it once by hand:

DISCORD_TOKEN="YOUR_TOKEN" venv/bin/python bot.py

The command can take a few minutes to appear in Discord after the first sync. Then stop the bot with Ctrl+C.

4. Keep it running with systemd

Back as root, store the token in a file only root can read:

install -m 600 /dev/null /etc/mybot.env
echo 'DISCORD_TOKEN=YOUR_TOKEN' > /etc/mybot.env

Create /etc/systemd/system/mybot.service:

[Unit]
Description=Discord bot
After=network-online.target
Wants=network-online.target
[Service]
User=bot
WorkingDirectory=/home/bot/mybot
EnvironmentFile=/etc/mybot.env
ExecStart=/home/bot/mybot/venv/bin/python bot.py
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable --now mybot
journalctl -u mybot -f     # live log

The bot now restarts after an error and after a VPS reboot. After changing the code: systemctl restart mybot.

5. With discord.js

The method is the same with Node.js: install a recent LTS version of Node.js, then run npm install discord.js in the bot folder. In the service, replace the ExecStart line with ExecStart=/usr/bin/node index.js. PM2 is a common alternative to systemd for Node.js projects.

6. Ports, intents and common errors

  • No port to open: the bot connects to Discord itself. Keep the firewall closed unless you add a website or a dashboard.
  • Privileged intents error at startup: the intent requested in the code is not enabled in the portal, or the other way round.
  • The bot cannot see message text: that is the Message Content intent. Prefer slash commands, which do not need it.
  • Beyond 2,500 servers, Discord requires sharding: discord.py handles it with AutoShardedClient.
⚠️ A token published by mistake on GitHub or in a screenshot gives full control of the bot. Regenerate it immediately in the portal, and never put it in the code: use the environment file above.

7. Which VPS for your bot

Type of botRAM
Moderation, commands, tickets on a few servers1 to 2 GB
Database, web dashboard, several bots2 to 4 GB
Music with ffmpeg or Lavalink4 GB and up
Bot connected to a local AI model (Ollama)8 to 16 GB

One VPS can host several bots, with one service and one token per bot. See our Discord bot VPS page, or the Ollama VPS if your bot uses a local AI model.

Frequently asked questions

Do I need a VPS to host a Discord bot?

Not for development: your computer is enough. For a bot that is always online, you need a machine that is always on and connected, which is what a VPS provides.

How much RAM does a Discord bot need?

1 to 2 GB is enough for a moderation or command bot. Allow 4 GB and up for a music bot, and more for several bots on the same server.

Do I need to open a port on the VPS?

No. The bot opens the connection to Discord itself. A port is only needed if you add a website, an API or a dashboard.

Why does my slash command not appear?

Check that the invite link included the applications.commands scope and that the sync ran at startup. A global command can take a few minutes to appear.

Linux NVMe VPS

Root access, Intel Xeon Gold and NVMe, delivered in 60 seconds. From 2,49 €/month.