PyHost
Discord bots

Discord.py Bot Hosting: Deploy, Connect and Stay Online

Get a discord.py bot from local development to a stable hosted process.

Published 2026-11-01 · PyHost Editorial

A Discord bot needs a continuously running Python process to maintain its gateway connection. A page that serves HTML is not enough. Hosting must support long-running processes, outbound HTTPS/WebSocket traffic, dependency installation and logs you can read when the bot disconnects.

Set up the application correctly

Create the application and bot in the Discord Developer Portal, invite it with the permissions your commands genuinely need, and enable only the privileged intents your code uses. Missing message-content intent can look like a broken bot even when it connected successfully. Avoid administrator permission for a bot that only responds to commands.

Keep the token outside source code:


import os

import discord



intents = discord.Intents.default()

client = discord.Client(intents=intents)

client.run(os.environ["DISCORD_BOT_TOKEN"])

Add discord.py to requirements.txt. Use a compatible Python version and test startup locally before uploading. If your project uses slash commands, allow for command registration to propagate and check that the bot was invited with the application commands scope.

Diagnose a failed deployment

Read the first exception in the log, not just the final “process exited” line. A missing token produces a configuration error; an invalid token fails login; missing packages fail during import; unavailable intents or permissions affect behavior after login. The fix depends on where startup stops.

Keep one bot process per token

When moving from a laptop to hosting, stop the local copy. Two copies of one bot can duplicate responses or compete for shared state. After deployment, run a real command in a test server, inspect logs, restart the hosted process and run it again. For larger bots, monitor memory growth and rate limits over time.

Ready to run your bot?

Explore PyHost plans and deploy your Python code from the browser.

Explore hosting plans