Python Discord bot hosting, without keep_alive hacks
discord.py, nextcord or py-cord: connect the repository, set the token, deploy. Python is detected from requirements.txt, the bot runs around the clock in its own sandbox, and every push redeploys it. The first bot is free.
Prepare the repository
Three things make a discord.py repository deploy cleanly anywhere:
- requirements.txt at the root, versions pinned. Major bumps of discord.py have broken login flows before, and "it worked yesterday" is almost always an unpinned dependency.
- The token from the environment, never in code:
client.run(os.environ["DISCORD_TOKEN"]). Request only the intents you use;message_content, members and presence are privileged. - A clear entrypoint:
main.pyorbot.pyat the root. That is what the host runs; a missing start command is found for you.
The two crashes every discord.py host sees
PrivilegedIntentsRequired: the intent is enabled in code but not in the Developer Portal under Bot, Privileged Gateway Intents. Flip the toggle there; the code alone is not enough.
LoginFailure: Improper token: a regenerated token, or an environment variable with a trailing space or quote. Copy it again exactly. The crash doctor reads the traceback and names both of these within a minute.
Deploy it
- Host a bot, connect GitHub, pick the repository. Python is detected from requirements.txt.
- Add
DISCORD_TOKENand any API keys as environment variables. - Deploy. The console streams your print() and logging output live.
- Every push to the default branch redeploys the bot. A bad deploy rolls back to the previous one in one click.
No keep_alive, ever
The Flask plus uptime-pinger pattern exists to trick sleeping platforms into staying awake. It wastes RAM, adds an attack surface and still fails when the pinger has an outage. Here the process simply runs, restarts if it crashes and comes back after node maintenance. Delete keep_alive.py; the bot gets lighter and more reliable at once.
Frequently asked questions
Which Python libraries are supported?
Anything on PyPI: discord.py, nextcord, py-cord, disnake, hikari. The runtime installs requirements.txt and runs your entrypoint.
Which Python version runs?
A current Python 3. Pin a version in a runtime file or a Dockerfile on a paid tier if a library needs a specific one.
Does a discord.py bot fit the free tier?
A typical utility bot idles at 60 to 120 MB, so yes. Bots that load large models or many voice connections want a paid tier.
Can the bot use a database?
Yes: MySQL, PostgreSQL, MongoDB and Redis are one click away on a private network, the first one free. SQLite on the bot's own disk also persists between restarts.