Quick answer
- Put your packages in
requirements.txt; the server installs them on every start. - Keep the token in a
.envfile and load it with python-dotenv, never in your code or on GitHub. - Set the bot file (default
bot.py) on the Startup page and press Start.
Prepare your project#
discord.py>=2.4
python-dotenvimport os
import discord
from dotenv import load_dotenv
load_dotenv()
intents = discord.Intents.default()
intents.message_content = True # also enable it in the Developer Portal
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.author.bot:
return
if message.content == "!ping":
await message.channel.send("pong")
client.run(os.environ["DISCORD_TOKEN"])DISCORD_TOKEN=your-bot-token-hereIf your bot reads message text, turn on Message Content Intent under Bot in the Discord Developer Portal, or message.content will be empty.
Deploy it#
- Create the bot server
On free Discord bot hosting, create a server and choose Python. You can pick the Python version (3.7 to 3.13) on the Startup page.
- Upload or connect GitHub
Upload
bot.py,requirements.txtand.envwith the file manager or SFTP. Or set Git Repo Address and Git Branch on the Startup page and reinstall; with Auto Update on, every start runsgit pull. Upload.envseparately so the token never touches GitHub. - Set the bot file
Check that Bot py file matches your main file name.
- Start
Press Start. The Console shows pip installing your packages, then "Logged in as ...".
Keeping it online#
Bot servers don't sleep. Free servers run on a timer: each click on Renew adds 12 hours, up to 48 hours stored, as often as you like. Renewing once or twice a day keeps the bot running around the clock. If the bot crashes, the Console shows the Python traceback; fix the code and press Restart.
Slash commands#
For slash commands use discord.app_commands with a CommandTree and call await tree.sync() once (for example in setup_hook). Global commands can take a while to appear; syncing to one test server is instant.
Building your first bot? See how to make a Discord bot. Writing in JavaScript instead? See how to host a discord.js bot.
Related: Free Discord Bot Hosting • Free Minecraft Server Hosting
Frequently asked questions#
Is 256 MB enough for a discord.py bot?
Yes for most bots: moderation, utility, tickets and economy bots use far less. Music bots with Lavalink need more.
How do I keep my token safe?
Put it in a .env file on the server and load it with python-dotenv. Add .env to .gitignore so it never reaches GitHub.
Does the bot restart after an update?
With Auto Update on and a GitHub repo set, press Restart and the server pulls the latest code before starting.



