How to host a Python Discord bot on ESN Hosting
Step-by-step: upload a discord.py (or any Python) bot to ESN Hosting, install packages with requirements.txt, set the main file and keep your token safe.
This guide gets a Python Discord bot (discord.py, py-cord, nextcord and so on) running 24/7 on an ESN server.
Before you start
- A server set up as Discord bot (Python). Use your free trial or a plan.
- Your bot's code, which runs on your own computer.
- A
requirements.txtfile listing the packages your bot uses, for examplediscord.py.
Steps
- Open your server from the panel dashboard and go to Files.
- Upload your bot. Drag your files in, or upload a
.zipand use Unarchive. Your main file andrequirements.txtmust be in the top folder, not inside a subfolder. See Uploading files. - Check the main file. Open Startup. The Main Python File variable is
main.pyby default. If your bot starts frombot.py, change it tobot.py. - Pick a Python version (optional). On the Startup page, the Docker Image box offers Python 3.12 or 3.13.
- Start it. Go to Console and choose Start. Every time the server starts, it runs
pip install -r requirements.txtand then starts your main file. - Watch the console for your bot's own "logged in" message. If you see an error, see Troubleshooting.
Keep your token safe
Never paste your bot token into a public channel or a screenshot. A simple way to keep it out of your code:
- Create a file called
.envin your server's top folder with one line:DISCORD_TOKEN=your-token-here - Add
python-dotenvtorequirements.txt. - Read it in your code:
import os
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
If a token ever leaks, reset it in the Discord Developer Portal right away and update your .env.
Privileged intents
If your bot reads message content or member lists, turn on the matching Privileged Gateway Intents on your app's Bot page in the Discord Developer Portal. Without them, Discord refuses the connection or your commands get no data.
Still stuck? Ask in the ESN Hosting Discord. Last updated October 27, 2026.