22 August 2026 · 10 min read

discord.py Hosting in 2026 — Where to Run Your Python Bot 24/7

The best hosting options for discord.py bots in 2026. Covers deployment, token security, intents setup, requirements.txt, and choosing between managed hosts, PaaS, and VPS for always-on discord.py bots.

discord.py is the most widely used Python library for Discord bots. This guide explains how to deploy a discord.py bot to a production host that keeps the gateway connected 24/7.

discord.py 2026 compatibility

discord.py 2.x (the discord.py package on PyPI) is actively maintained and supports:

  • Python 3.8–3.12 (3.11 and 3.12 recommended)
  • Discord's v10 API
  • Application commands (slash commands) via discord.app_commands
  • Voice support via discord[voice]
  • Privileged intents (Message Content, Guild Members, Guild Presences)

Minimum requirements.txt for discord.py

discord.py>=2.3.0

For voice support:

discord.py[voice]>=2.3.0

For type-checking support:

discord.py>=2.3.0
PyNaCl>=1.5.0

A complete minimal discord.py bot

# bot.py
import os
import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.message_content = True  # requires privileged intent in Developer Portal

bot = commands.Bot(command_prefix="!", intents=intents)

@bot.event
async def on_ready():
    print(f"Logged in as {bot.user} (ID: {bot.user.id})")
    print("------")

@bot.command()
async def ping(ctx):
    """Check if the bot is alive."""
    await ctx.send(f"Pong! Latency: {round(bot.latency * 1000)}ms")

@bot.tree.command(name="hello", description="Say hello")
async def hello(interaction: discord.Interaction):
    await interaction.response.send_message(f"Hello, {interaction.user.mention}!")

@bot.event
async def setup_hook():
    # Sync slash commands to Discord
    await bot.tree.sync()

bot.run(os.getenv("TOKEN"))

Key points:

  • os.getenv("TOKEN") reads the token from an environment variable — never hardcode it
  • setup_hook is the right place to sync slash commands (runs before on_ready)
  • intents.message_content = True requires enabling the Message Content privileged intent in the Discord Developer Portal

Enabling privileged intents

  1. Go to discord.com/developers/applications
  2. Select your app → Bot tab
  3. Under Privileged Gateway Intents, enable:
  4. Message Content Intent — required if you read message.content
  5. Server Members Intent — required if you track member join/leave
  6. Presence Intent — required if you read member presence/activity

If you enable these in code but not in the portal, discord.py raises:

discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been enabled in the developer portal.

Hosting options for discord.py

Managed — getDiscordBot ($4.99/mo)

getDiscordBot is purpose-built for Python Discord bots. There is no Git, no Docker, no server configuration.

How to deploy discord.py on getDiscordBot:

  1. Sign up free — 1-month trial, no card
  2. Click New Bot
  3. Paste your bot.py in the Code tab
  4. In the Packages tab, paste: discord.py>=2.3.0
  5. In the Secrets tab, add TOKEN = your bot token
  6. Click Deploy

The platform installs your dependencies and starts python bot.py. Live logs stream in the dashboard. If the process crashes, you get an email with the last 50 lines.

Discord.py-specific notes for getDiscordBot: - Python 3.10, 3.11, and 3.12 all available - Voice support works (FFmpeg is included) - Slash command sync works on startup via setup_hook

PaaS — Railway

Railway deploys from GitHub. Create a repo with your bot.py and requirements.txt, connect it to Railway, and it auto-deploys.

# Procfile (optional — Railway auto-detects Python)
worker: python bot.py

Cost: ~$5–9/mo per service on Hobby plan.

PaaS — Render

Render Background Workers stay alive without HTTP requests. Connect your GitHub repo, set the start command to python bot.py, and add TOKEN as an environment variable.

Cost: $7/mo for a paid Background Worker.

VPS

Any Linux VPS works. After SSH-ing in:

# Install Python 3.12
sudo apt update && sudo apt install -y python3.12 python3.12-venv

# Create virtual environment
python3.12 -m venv .venv
source .venv/bin/activate
pip install discord.py

# Run with systemd (see systemd section below)

Cost: $4–6/mo, but you manage everything.

Handling crashes in discord.py

discord.py has built-in reconnect logic for temporary network issues. What it cannot handle is unhandled Python exceptions that crash the process entirely.

Catch errors in commands:

@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandNotFound):
        return  # ignore
    if isinstance(error, commands.MissingPermissions):
        await ctx.send("You do not have permission to use this command.")
        return
    # Log unexpected errors
    print(f"Unexpected error: {error}")
    raise error

Catch errors in app commands (slash commands):

@bot.tree.error
async def on_app_command_error(interaction: discord.Interaction, error: discord.app_commands.AppCommandError):
    await interaction.response.send_message("An error occurred.", ephemeral=True)
    raise error

On getDiscordBot, the process auto-restarts after a crash and you get an email. On a VPS, you need systemd's Restart=always to achieve the same.

Token security for discord.py

The most common mistake is committing the token to GitHub. Discord scans GitHub and invalidates exposed tokens.

Always use environment variables:

# correct
bot.run(os.getenv("TOKEN"))

# wrong — never do this
bot.run("MTIzNDU2Nzg5MDEy...")

For local development, use python-dotenv:

pip install python-dotenv
# at the top of bot.py, before bot.run()
from dotenv import load_dotenv
load_dotenv()  # loads TOKEN from .env file
# .env (add this to .gitignore)
TOKEN=your_token_here

On getDiscordBot, the Secrets panel stores your token encrypted and injects it as TOKEN at runtime.

Comparing discord.py hosting at a glance

Feature getDiscordBot Railway Render VPS
Price (1 bot) $4.99/mo ~$5–9/mo $7/mo ~$4–6/mo + time
Crash email ✅ ❌ ❌ ❌
Auto-restart ✅ ✅ ✅ If configured
Paste deploy ✅ ❌ ❌ ❌
discord.py 2.x ✅ ✅ ✅ ✅
Live log stream ✅ ✅ ✅ Via SSH
Token security Secrets panel Env vars Env vars You manage

Next steps

FAQ

Where can I host a discord.py bot?

discord.py bots can be hosted on purpose-built platforms like getDiscordBot ($4.99/mo), general PaaS services like Railway or Render, game panel hosts like PebbleHost, or any Linux VPS. getDiscordBot is the easiest option — paste bot.py, add your token, and deploy.

Does discord.py work on Railway or Render?

Yes, discord.py works on both. Railway deploys from a GitHub repo and costs $5-9/mo per service. Render Background Workers cost $7/mo. Neither sends crash emails by default. For a simpler setup, getDiscordBot is purpose-built for discord.py.

What Python version should I use for discord.py?

discord.py 2.x requires Python 3.8 or higher. Python 3.11 or 3.12 are recommended in 2026 for performance improvements and full type annotation support.

How do I install discord.py on my host?

Add discord.py to a requirements.txt file in your project root. Most hosts install it automatically. On getDiscordBot, paste your requirements.txt in the Packages tab. On Railway or Render, the platform reads requirements.txt from your repo.

Can discord.py and nextcord be used interchangeably?

They are API-compatible forks with minor differences. nextcord 2.x is largely a drop-in replacement for discord.py 2.x. Both are supported on getDiscordBot.

getDiscordBot facts: Python 3.10–3.12 (discord.py, nextcord, py-cord, hikari). Paste bot.py, set TOKEN, stay on the Discord gateway. Starter $4.99/mo (1 bot, 128MB). Pro $9.99/mo (3 bots).

Loading