← Back to Blog
AAbhijot Singh · Updated July 2026 · 11 min read

How to Host a Discord Bot 24/7 on a Cloud Server

Your Discord bot works great on your computer — but it goes offline whenever you close your laptop. Here's how to deploy it to a cloud server so it stays online 24/7, automatically restarts after crashes, and runs without your computer being on.

Why You Need a Cloud Server for Your Bot

Running a Discord bot on your personal computer has major limitations:

A cloud server solves all these problems. It's always on, always connected, and can automatically restart your bot if it crashes.

Option 1: Managed Bot Hosting (Easiest)

The simplest approach is using a dedicated bot hosting service with a game panel like Pterodactyl. This is ideal if you don't want to manage a server or learn Linux commands.

How It Works on Azion Cloud

  1. Create a bot hosting service — Select the Bot Hosting plan from our hosting page
  2. Choose your runtime — Select the egg matching your bot's language:
    • Node.js — For discord.js bots
    • Python — For discord.py or py-cord bots
    • Java — For JDA bots
    • Generic — For custom runtimes
  3. Upload your bot files — Use the built-in file manager or SFTP to upload your bot's code
  4. Set environment variables — Add your bot token and any API keys in the Startup tab
  5. Start the bot — Click the Start button. The panel handles crash recovery automatically.

That's it. No SSH, no Linux commands, no process managers. The panel monitors your bot and restarts it if it crashes.

Option 2: VPS with PM2 (Node.js Bots)

If you're running a Node.js bot and want full control, deploy to a VPS using PM2 — a production process manager that handles auto-restart, logging, and monitoring.

Step 1: Connect to Your VPS

ssh root@your-server-ip

Step 2: Install Node.js

# Install Node.js 20 LTS
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs

# Verify installation
node --version
npm --version

Step 3: Upload and Install Your Bot

# Create directory for your bot
mkdir -p /opt/discord-bot
cd /opt/discord-bot

# Upload your bot files via SFTP, then install dependencies
npm install

Step 4: Set Up PM2

# Install PM2 globally
npm install -g pm2

# Start your bot with PM2
pm2 start index.js --name "my-discord-bot"

# Enable auto-restart on server reboot
pm2 startup
pm2 save

# View bot status
pm2 status

# View bot logs
pm2 logs my-discord-bot

PM2 provides:

Option 3: VPS with systemd (Python Bots)

For Python bots, systemd is the standard Linux process manager. It's built into every modern Linux distribution.

Step 1: Install Python and Dependencies

sudo apt update
sudo apt install python3 python3-pip python3-venv -y

# Create project directory
mkdir -p /opt/discord-bot
cd /opt/discord-bot

# Create virtual environment
python3 -m venv venv
source venv/bin/activate

# Install your bot's dependencies
pip install discord.py
# or: pip install -r requirements.txt

Step 2: Create a systemd Service

sudo nano /etc/systemd/system/discord-bot.service

Paste this configuration:

[Unit]
Description=My Discord Bot
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/opt/discord-bot
ExecStart=/opt/discord-bot/venv/bin/python3 bot.py
Restart=always
RestartSec=10
Environment=DISCORD_TOKEN=your-token-here

[Install]
WantedBy=multi-user.target

Step 3: Enable and Start

# Reload systemd to pick up the new service
sudo systemctl daemon-reload

# Start the bot
sudo systemctl start discord-bot

# Enable auto-start on boot
sudo systemctl enable discord-bot

# Check status
sudo systemctl status discord-bot

# View logs
journalctl -u discord-bot -f

The Restart=always directive tells systemd to restart your bot whenever it exits, with a 10-second delay between restarts. This handles crashes, unhandled exceptions, and any situation where the process stops.

Security Best Practices

Never Hardcode Your Token

Your Discord bot token is equivalent to a password. Never put it directly in your source code or commit it to Git. Use environment variables or a .env file:

# .env file (add to .gitignore!)
DISCORD_TOKEN=your-token-here
DATABASE_URL=mongodb://localhost:27017/mybot

In your bot code (Node.js):

require('dotenv').config();
client.login(process.env.DISCORD_TOKEN);

Use a Firewall

If using a VPS, configure a firewall to only allow necessary ports:

sudo ufw allow ssh
sudo ufw enable

Discord bots only make outgoing connections — they don't need any incoming ports open (except SSH for management).

Keep Dependencies Updated

Regularly update your bot's dependencies to patch security vulnerabilities:

# Node.js
npm update
npm audit fix

# Python
pip install --upgrade discord.py

Troubleshooting Common Issues

Which Option Should You Choose?

Managed bot hosting — Best if you want simplicity. No Linux knowledge needed. Just upload and run.

VPS with PM2/systemd — Best if you want full control, need to run multiple bots, or want to host other services alongside your bot.

Azion Cloud offers both options. Our bot hosting provides a managed Pterodactyl panel experience, while our VPS plans give you full root access to set up PM2 or systemd yourself. Either way, your bot stays online 24/7.

Frequently Asked Questions

Free tiers from Oracle Cloud (Always Free), Railway, and Render exist but have significant limitations: cold starts, sleep after inactivity, limited CPU/RAM, and potential IP bans from Discord for running on shared IPs. For a production bot that needs to be online 24/7 without interruptions, paid hosting is necessary. Azion Cloud bot hosting starts at ₹99/month with a dedicated IP.

Azion Cloud supports any language that runs on Linux: Node.js (discord.js), Python (discord.py, Pycord, nextcord), Java (JDA), Go, Rust, and more. We provide a base Ubuntu environment — you install your runtime and dependencies. Our Pterodactyl panel has pre-configured eggs for Node.js and Python bots to make setup easier.

A basic Discord bot (under 100 servers) needs about 128-256MB RAM. A bot with 500+ servers and complex features (music, image generation, databases) needs 512MB-1GB. Economy bots with SQLite databases need extra disk I/O. Azion Cloud bot hosting plans start with 512MB RAM, suitable for most small-medium bots.

Use PM2 (for Node.js/Python): `npm install -g pm2 && pm2 start bot.js && pm2 startup`. PM2 keeps your bot running, restarts it on crash, and starts it automatically on server reboot. Alternative: use `systemctl` to create a service. Never use `nohup` for production — it doesn't handle crashes or reboots. Azion Cloud VPS plans let you set these up directly.

A
Abhijot Singh
Founder & Lead Developer, Azion Cloud

21-year-old developer from Punjab, India. I founded Azion Cloud and run the entire infrastructure "” from server setup to panel customization. Everything I write comes from real hands-on experience running this hosting company, not theoretical knowledge.