Host a discord.py Bot 24/7 — Without keep_alive Hacks (2026)

Bernis·

If you learned discord.py from older tutorials, you’ve probably seen the keep_alive.py trick — a tiny Flask server plus an uptime pinger to stop a free host from sleeping your bot. On real hosting, you don’t need any of that. Here’s a clean 24/7 setup.

Prepare the repo

Three things make a discord.py repo deploy cleanly anywhere:

  1. requirements.txt at the repo root, with pinned versions:
discord.py==2.4.0
aiohttp>=3.9

Pin discord.py — major bumps have broken login flows before, and “it worked yesterday” bugs are almost always an unpinned dependency.

  1. Token from the environment, never in code:
import os
import discord

intents = discord.Intents.default()
intents.message_content = True  # only if you actually read messages

client = discord.Client(intents=intents)
client.run(os.environ["DISCORD_TOKEN"])
  1. A clear entrypointmain.py or bot.py at the root. That’s what the host runs.

The two crashes every discord.py host sees

PrivilegedIntentsRequired — you enabled message_content (or members/presence) in code but not in the Developer Portal → Bot → Privileged Gateway Intents. Flip the toggle there; the code alone isn’t enough.

LoginFailure: Improper token — regenerated token, or an env var with a trailing space/quote. Re-copy it exactly. (On FadeHost the crash doctor reads the traceback and points at exactly these — the two most common bot crashes in existence.)

Deploy it on FadeHost

  1. Bots panel → Connect GitHub → pick the repo. Python is detected from requirements.txt automatically.
  2. Add DISCORD_TOKEN (and any API keys) as environment variables.
  3. Deploy. The live console shows your print() output and logging in real time.
  4. Every git push redeploys the bot automatically — your workflow becomes: edit, push, done.

Your first bot is free — 256MB, which runs a typical discord.py utility bot comfortably (most idle at 60–120MB). Need a database for economy/leveling? A managed MySQL/Postgres/Redis is one click away on a private network, no public exposure.

No keep_alive, ever

The Flask + UptimeRobot 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. On always-on hosting the bot process simply runs, gets restarted if it crashes, and comes back after node maintenance. Delete keep_alive.py; your bot gets lighter and more reliable at the same time.

More: the full hosting options comparison · what the free tier includes · running discord.js instead?