How to host a discord.py bot 24/7
Run your discord.py bot around the clock on ESN, without leaving your computer on. About 10 minutes from upload to online.
Before you start #
You need an ESN account (create one) and a bot plan from $0.50/month on the plans page. Most small bots run fine on Nano (256 MB) or Starter (512 MB); see how much RAM a bot needs.
- Your bot works on your own computer with
python main.py(or your main file). - A
requirements.txtin the same folder that lists your packages, for examplediscord.pyandpython-dotenv. One package per line. - Your bot token from the Discord Developer Portal (how to get it).
Get your code ready #
import os
import discord
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv()
intents = discord.Intents.default()
intents.message_content = True # only if you use prefix commands or read messages
bot = commands.Bot(command_prefix="!", intents=intents)
@bot.event
async def on_ready():
print(f"Logged in as {bot.user}")
bot.run(os.getenv("DISCORD_TOKEN"))Put DISCORD_TOKEN=your-token-here in a .env file next to your main file. If you set message_content = True, also turn on Message Content Intent in the Developer Portal under Bot, or the bot will fail to connect (see privileged intents required).
Upload it to ESN #
- Open your server from the panel dashboard. It should be set up as Discord bot (Python).
- Go to Files and upload your files, or upload a
.zipand choose Unarchive. Your main file,requirements.txtand.envmust be in the top folder. Don't upload avenvfolder. See uploading files. - Go to Startup. The Main Python File is
main.pyby default. If your bot starts frombot.py, change it. - On the same page, the Docker Image box offers Python 3.12 or 3.13. Current discord.py works on both.
Start it and keep it online #
- Go to Console and press Start. Every start runs
pip install -r requirements.txtand then your main file. - Wait for your own line, like Logged in as MyBot#1234. That means it's online.
- Close the tab. The bot keeps running on ESN when your PC is off.
- Added a package? Add it to
requirements.txtand press Restart.
Common discord.py errors #
- LoginFailure: Improper token has been passed: wrong or reset token. See fix it here.
- PrivilegedIntentsRequired: turn the intent on in the Developer Portal. See this fix.
- ModuleNotFoundError: No module named 'discord': the package is missing from
requirements.txt. Note the package isdiscord.py, notdiscord. See this fix. - Missing intents argument: pass
intents=to your client or bot. See this fix. - Keeps disconnecting: see discord.py bot keeps disconnecting.
FAQ #
Do I need a venv on the server?
No. The server installs your requirements.txt on every start. Leave your local venv folder out of the upload.
Does this work for py-cord or nextcord?
Yes. Put that package in requirements.txt instead of discord.py and the same steps apply.
Will my Python bot stay online when my PC is off?
Yes. It runs on ESN's servers, not your computer.
How much does it cost?
ESN bot hosting starts from $0.50/month. All plans are on panel.esnoffical.com/plans.
Still stuck? Use the live chat on the panel or ask in the ESN Systems Discord. Last updated November 3, 2026.