Why Your Discord Bot Keeps Going Offline
Diagnose why Discord bots drop offline—from free web-host idle shutoffs and renewal timers to unhandled exceptions and OOM kills.
The 5 most common reasons Discord bots go offline
A Discord bot needs a persistent WebSocket connection to Discord's Gateway so it stays green in your member list and answers commands immediately. When a bot keeps dropping offline, the cause almost always falls into one of five buckets:
1. Free web-app hosts shut down idle containers
General web hosts like Render's free tier, Replit, or Koyeb are built for HTTP websites. When nobody visits a web URL for 15–60 minutes, they spin the container down — severing your bot's outbound Discord Gateway connection until a request wakes the web port. Dummy Express servers and external pingers are brittle and often break Terms of Service.
2. Ad-supported renewal timers expired
Free bot hosts often require clicking a dashboard renewal button or watching ads every 24 to 96 hours. Miss one check-in and the host stops (or eventually deletes) your bot.
3. Unhandled promise rejections or runtime exceptions
One unexpected Missing Permissions
error on a DM or deleted channel can crash an entire Node.js or Python process if your command handler does not catch errors cleanly.
4. Running out of memory (OOM kills)
Unbounded caches (like storing every message in a global array), heavy image/canvas rendering on tiny RAM caps, or starting Node via npm start
instead of node index.js
can push a bot over its container memory ceiling and cause sudden restarts.
5. Reset token or missing privileged intent
If you pushed your bot token to a public GitHub repo, Discord automatically revokes it within seconds (4004
/ 401
). Likewise, requesting an intent disabled in the Developer Portal drops the bot immediately (error 4014).
Guard your bot against unhandled crashes
Even on rock-solid hosting, add global error logging and wrap Discord API calls in try / catch
blocks so a single bad interaction cannot knock your whole bot offline:
client.on('interactionCreate', async (interaction) => {
if (!interaction.isChatInputCommand()) return;
try {
await runCommand(interaction);
} catch (err) {
console.error('Command failed:', err);
const reply = { content: 'Something went wrong running that command.', ephemeral: true };
if (interaction.replied || interaction.deferred) {
await interaction.followUp(reply).catch(() => {});
} else {
await interaction.reply(reply).catch(() => {});
}
}
});
process.on('unhandledRejection', (err) => {
console.error('Unhandled promise rejection:', err);
});
@bot.tree.error
async def on_app_command_error(interaction: discord.Interaction, error: app_commands.AppCommandError):
print(f"Slash command error: {error!r}")
if not interaction.response.is_done():
await interaction.response.send_message(
"Something went wrong running that command.", ephemeral=True
)
Trim avoidable memory usage
- Start Node directly: Use
node index.jsinstead ofnpm startto avoid keeping an extra npm parent process in memory (~40 MB saved). - Avoid unnecessary intents: Do not turn on
GuildPresencesorGuildMembersunless you actually need them; large member caches eat RAM quickly. - Store state on disk or in a database: Keep user data and logs in SQLite, PostgreSQL, or MongoDB rather than unbounded in-memory arrays or Maps.
- Turn off timers when not in use: Each timer execution consumes resources. If there's nothing to wait for, disable the timer to free up memory and CPU cycles.
Keep your bot online 24/7 on Blip Host
Unlike general web hosts that shut down idle apps or free bot hosts with 4-day renewal timers, Blip Host is built from the ground up to keep Discord bots connected around the clock. If your bot ever crashes, runs out of memory, loses its token, or hits a Discord error, Blip Host surfaces the exact cause in plain English and notifies you by email or Discord webhook before your server notices.