Skip to content
EndercloudKnowledge Base
GuideBot Hosting

How to host a Python Discord bot

Upload your bot files with a requirements.txt, set your main .py file and Python version in the Startup tab, then click Start and check the console.

Updated 3 min read
Difficulty:
Beginner
Time:
10 minutes
On this page

To run a Python bot (discord.py, Pycord, nextcord, a Telegram bot and so on) on Endercloud, upload your code with a requirements.txt file, choose your main .py file and Python version in Startup, and click Start.

Step 1: Create requirements.txt

requirements.txt is a plain text file that lists the packages your bot needs, one per line. The server installs everything in it when the bot starts. Example for a discord.py bot:

discord.py
python-dotenv

You can pin versions if you want the same versions every time, for example discord.py==2.4.0. Use the package names as they appear on PyPI, the name you would type after pip install.

Don't upload a virtual environment folder such as venv or .venv, or __pycache__. They are large and don't work on the server.

Step 2: Upload your files

  1. Open your bot in the Game Panel and go to Files.

  2. Upload your .py files and requirements.txt into the main folder, not inside an extra sub-folder.

  3. For many files, upload a .zip and unarchive it, or use SFTP. See Using the file manager.

  4. Store your token in a .env file, not in the code. See Keep your bot token safe.

Step 3: Set the main file and Python version

All of the bot's start settings are in the Startup tab. The exact variable names depend on the bot language, so read the description under each one:

  • Find the variable for the file that starts your bot and enter your file name, for example main.py or bot.py. The name must match exactly, including capital letters.

  • If there is a variable for the requirements file, leave it as requirements.txt unless your file has another name.

  • Pick the Python version in the Docker Image list. Use a version your libraries support; a recent Python 3 release is a safe default for discord.py.

Can't tell which variable is which? Open a ticket and we will point you to the right one.

Step 4: Start and check the console

  1. Click Start and open Console.

  2. The first start installs your packages with pip, which can take a minute. Watch the console to confirm the packages from requirements.txt are installed.

  3. Wait for your bot's "logged in" message and check that it is online in Discord.

Common console errors

Error

What to do

ModuleNotFoundError: No module named 'x'

Add the package to requirements.txt and restart. The import name and the PyPI name can differ (for example you import dotenv but install python-dotenv).

can't open file '/home/container/main.py'

The main file setting doesn't match your file name, or the file is in a sub-folder.

LoginFailure: Improper token has been passed

The token is wrong or was reset. Copy a new one from the Discord Developer Portal.

PrivilegedIntentsRequired

Enable the intent your code uses (often Message Content) in the Developer Portal under Bot → Privileged Gateway Intents.

Syntax errors after changing version

Your code or a package needs a different Python version. Change the Docker Image in Startup and restart.

If the bot goes offline after running for a while, see My bot keeps going offline.

Frequently asked questions

Do I need to run pip install myself?

Normally no. Packages listed in requirements.txt are installed when the bot starts, so keep the file up to date and restart after changing it. If the console doesn't show pip installing them, check the requirements setting in Startup or open a ticket.

My bot reads messages but the content is empty

Turn on the Message Content intent in the Developer Portal and enable it in your code, for example with intents.message_content = True in discord.py.

Can I switch my bot from Python to Node.js later?
Host your botInstant setup · 24/7 support · DDoS protection

Was this article helpful?

Related articles

Join Our Discord

Connect with our community of gamers and developers

Get instant support, share experiences, and stay updated with the latest news

Join Discord