Host a Python Discord bot for free
Is your bot written with discord.py, py-cord, nextcord or disnake? On Kravn Hosting it runs 24/7 on Python 3.13 or 3.12, for free, with no credit card. This guide shows what to prepare, how to upload it and how to fix the most common errors.
Prepare your bot
Your folder needs at least these files:
main.py(orbot.py, orapp.py): the file that starts your bot.requirements.txt: the packages your bot needs..env: your Discord token. It stays on the server, never put it on GitHub.
A simple requirements.txt:
discord.py
python-dotenv
The .env file:
DISCORD_TOKEN=your-token
A minimal main.py that answers !ping:
import os
import discord
from dotenv import load_dotenv
load_dotenv()
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f"Logged in as {client.user}")
@client.event
async def on_message(message):
if message.content == "!ping":
await message.channel.send("Pong!")
client.run(os.environ["DISCORD_TOKEN"])
Get it online
- Create your account with Discord, then log in to the panel and open your bot.
- Pick Python (3.13 or 3.12) in the Startup tab. Leave the main file empty: Kravn looks for
main.py, thenbot.py, thenapp.py. - Upload your files in the Files tab or over SFTP. Do not upload your
venvfolder: it is created again on the server. - Press Start. On the first start, Kravn creates a Python environment (
.venv) and installs yourrequirements.txt. After that, it only reinstalls when that file changes.
Is your code on GitHub? Deploy it from GitHub, it updates on every restart.
Common errors
ModuleNotFoundError: the package is missing fromrequirements.txt. Add it and restart.PrivilegedIntentsRequired: your code asks for an intent that is not enabled. In the Discord developer portal, Bot tab, enable Message Content Intent (and Server Members Intent if you use it).LoginFailure: Improper token: the token is wrong or was reset. Copy the new one into your.env.KeyError: 'DISCORD_TOKEN': the.envis not read. Check that it sits next tomain.pyand thatpython-dotenvis inrequirements.txt.- The bot stops with no message: it may be out of memory. Each bot has 256 MB of RAM, enough for a normal bot, but not for loading large files or AI models in memory.
Good to know
- You get 256 MB of RAM, 768 MB of disk and 20% of a CPU core.
- Only a Discord bot is allowed: a website, a proxy or any other program is stopped.
- Your bot is paused if it stays offline for more than 5 days. Your files are kept and you start it again yourself from the panel.
- You can switch from Python to Node.js later, in the Startup tab.