22 August 2026 · 13 min read
How to Host a Discord Bot 24/7 in 2026 — Deploy in 5 Minutes from $4.99/mo
Step-by-step guide to hosting a Python Discord bot 24/7 in 2026. No Linux required. Covers discord.py setup, token security, and picking a host that never drops the gateway — from $4.99/mo.
Your Discord bot goes offline every time you close your laptop. This guide shows you exactly how to move it to a cloud host that keeps the gateway connected permanently — no Linux, no SSH, no server management.
If you're looking for a free option: there isn't one that works reliably. Free tiers sleep your bot. Paid hosting starts at $4.99/mo — getDiscordBot includes a 30-day trial so you can confirm it works before paying.
What "hosting a Discord bot" actually means
A Discord bot is a Python process that opens a persistent WebSocket connection to Discord's gateway servers. As long as the process runs, your bot is online. When the process stops — because your laptop sleeps, a free tier pauses the container, or the code crashes — Discord sees the bot go offline within seconds.
Hosting means running that Python process on a server you do not own, so it stays up independently of your own computer.
Step 1 — Build a working bot locally first
If you haven't written your bot yet, start with a minimal working example:
# bot.py
import os
import discord
intents = discord.Intents.default()
intents.message_content = True
bot = discord.Client(intents=intents)
@bot.event
async def on_ready():
print(f"Logged in as {bot.user}")
@bot.event
async def on_message(message):
if message.author == bot.user:
return
if message.content.lower() == "!ping":
await message.channel.send("Pong!")
bot.run(os.getenv("TOKEN"))
Install the library locally:
pip install discord.py
Test it with your token:
TOKEN=your_token_here python bot.py
If you see Logged in as YourBot#1234, the bot works locally.
Step 2 — Create your bot token (if you haven't)
- Go to discord.com/developers/applications
- Click New Application, give it a name
- Go to the Bot tab and click Add Bot
- Under Token, click Reset Token and copy it immediately
- Under Privileged Gateway Intents, enable Message Content Intent if your bot reads messages
Keep the token secret. Never commit it to GitHub. We will store it as an environment variable.
Step 3 — Create a requirements.txt
Your host needs to know what Python packages to install. Create a requirements.txt file in the same directory as bot.py:
discord.py>=2.3.0
If you use nextcord instead:
nextcord>=2.6.0
For py-cord:
py-cord>=2.6.0
For hikari with lightbulb:
hikari>=2.0.0
hikari-lightbulb>=2.2.0
Add any other packages your bot needs — aiohttp, Pillow, sqlalchemy, etc. All PyPI packages work.
Step 4 — Choose a host
This is where most guides stop. They tell you to "deploy to a server" without explaining the tradeoffs.
Option A — Managed host (recommended for beginners)
A managed host handles the server, Python environment, and process management. You paste your code and it runs.
getDiscordBot is built specifically for Python Discord bots:
- Paste bot.py directly in the browser — no Git required
- The platform installs your requirements.txt automatically
- Your TOKEN goes in the Secrets panel — never exposed in code or logs
- Auto-restart when the bot crashes
- Crash email with the last log lines
- Live log tail in the dashboard
Cost: $4.99/mo after a free 1-month trial. Start the free trial →
Option B — General PaaS (Railway, Render)
Railway and Render can host a Python process, but they are built for web apps. Setup requires:
- A GitHub repo with your bot code
- A
Procfileorrailway.toml - Connecting your repo to the platform
This works but adds overhead. Railway starts at ~$5–9/mo per service; Render's paid background worker is $7/mo. Neither sends crash emails by default.
Option C — VPS (Hetzner, DigitalOcean, Vultr)
A VPS gives you full control but requires Linux knowledge:
# On the VPS
sudo apt update && sudo apt install -y python3 python3-pip
pip install discord.py
# Create a systemd service to auto-restart
Cost: ~$4–6/mo but you manage everything including security updates, disk space, and crash monitoring.
Step 5 — Deploy to getDiscordBot (step by step)
- Sign up at getdiscordbot.com/accounts/signup/ — no card required for the trial
- Click New Bot in the dashboard
- In the Code tab, paste your
bot.pycontent - In the Packages tab, paste your
requirements.txtcontent - In the Secrets tab, add:
- Key:
TOKEN - Value: your bot token from the Discord Developer Portal
- Click Deploy
Within 30 seconds your bot appears online in Discord. The dashboard shows live logs:
[INFO] Logging in as YourBot#1234
[INFO] Connected to Discord gateway
Logged in as YourBot#1234
Step 6 — Invite the bot to your server
You need to generate an invite link with the right permissions:
- Go to the Discord Developer Portal
- Select your application → OAuth2 → URL Generator
- Check bot under Scopes
- Check the permissions your bot needs (Send Messages, Read Messages, etc.)
- Copy the generated URL and open it in your browser
- Select your server and click Authorize
Step 7 — Handle crashes properly
Even well-written bots crash. Common causes:
- Unhandled exceptions in event handlers
- Discord API rate limits (HTTP 429)
- Network timeouts during gateway reconnection
- Bugs triggered by unexpected user input
Protect against unhandled exceptions:
@bot.event
async def on_error(event, *args, **kwargs):
import traceback
print(f"Error in {event}:")
traceback.print_exc()
For slash command bots (discord.py 2.x):
@bot.tree.error
async def on_app_command_error(interaction, error):
await interaction.response.send_message(
"Something went wrong.", ephemeral=True
)
raise error # still logs it
getDiscordBot auto-restarts on crashes and emails you the last 50 log lines so you can diagnose the issue.
Step 8 — Keep your token safe
The most common mistake beginners make is committing their token to GitHub. GitHub bots actively scan for Discord tokens and report them; Discord invalidates exposed tokens within minutes.
Rules:
- Always read the token from an environment variable:
os.getenv("TOKEN") - Never hardcode it in
bot.py - Add
.envto your.gitignoreif you use python-dotenv locally - Rotate the token immediately if you think it was exposed
On getDiscordBot, the Secrets panel stores your TOKEN encrypted and injects it as an environment variable at runtime — it never appears in your code or logs.
Common mistakes and fixes
| Problem | Likely cause | Fix |
|---|---|---|
| Bot goes offline randomly | Host is sleeping the process | Switch to a paid always-on host |
discord.errors.LoginFailure |
Invalid or revoked token | Reset token in Developer Portal |
| Bot doesn't receive messages | Message Content Intent not enabled | Enable in Bot settings in Developer Portal |
| Commands not showing up | Slash commands not synced | Call await bot.tree.sync() on startup |
ModuleNotFoundError |
Package not in requirements.txt | Add it and redeploy |
| Bot responds to itself | Missing if message.author == bot.user: return |
Add that check at the top of on_message |
What about 24/7 uptime guarantees?
No host offers 100% uptime. What matters for a Discord bot:
- Auto-restart after crash — the bot should recover within seconds of an unhandled exception
- No intentional sleeping — the host should never pause your process due to inactivity
- Gateway reconnect logic — discord.py handles reconnects automatically on temporary network issues
getDiscordBot's infrastructure is on the same VPS as litelambda.in (12+ days uptime shown in system metrics). For community bots, this is more than sufficient.
Next steps
- Compare hosting prices for 2026 →
- discord.py hosting deep dive →
- Always-on hosting explained →
- Start your free trial — no card required →
FAQ
How do I host a Discord bot 24/7 for free?
Truly free always-on hosting does not exist. Free tiers on Replit, Render, and Railway either sleep the process or have been removed. getDiscordBot offers a 30-day free trial with no credit card required, then $4.99/mo.
Why does my Discord bot go offline when I close my laptop?
Your bot is running on your local machine. Closing the laptop stops the Python process and drops the Discord WebSocket gateway. You need a cloud host that runs 24/7 independently — getDiscordBot keeps it online for $4.99/mo.
Do I need to know Linux to host a Discord bot?
Not with a managed host like getDiscordBot. You paste your bot.py code in the dashboard and the platform handles the server, Python environment, and process management. No SSH, no systemd.
What is a bot token and how do I keep it safe?
A bot token is a secret string from the Discord Developer Portal that authenticates your bot. Never put it in source code. Store it as an environment variable (TOKEN) and read it with os.getenv('TOKEN'). getDiscordBot has a built-in Secrets panel for this.
Can I use discord.py, nextcord, or py-cord?
Yes. discord.py, nextcord, py-cord, and hikari all work on getDiscordBot. Add them to requirements.txt and they install automatically on deploy.
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).