Skip to content
Puranode

Guide

Discord Bot Keeps Going Offline? Causes and Fixes

A Discord bot goes offline for one of two reasons: its process stopped, or the process is running but has lost its gateway connection and is not getting it back. The usual culprits are a machine that sleeps or a terminal that closes, an unhandled error with nothing to restart the bot, a missing privileged intent or reset token that Discord refuses outright, rate limits, a host that suspends idle apps, and memory that runs out. Each leaves a different trace in the logs, and each has a specific fix below.

Published

FAQ

Frequently asked

Why does my Discord bot go offline when I close my laptop?

Because the bot is a process on that laptop. Sleep suspends the process and its network connection, and closing the terminal it was started from stops it. A bot that needs to stay online needs a machine that stays on, with systemd, PM2 or Docker restarting it.

Why does my bot go offline for a few seconds and come back?

That is normally the gateway reconnecting. Missed heartbeat acknowledgements, network drops and Discord's own reconnect requests all close the connection, and discord.py and discord.js resume the session automatically. Frequent gaps are worth checking for blocking code that delays heartbeats.

My bot is online but ignores messages. Is it broken?

Usually it is missing the Message Content intent. Without it, the text of other people's messages arrives empty, so prefix commands do nothing, while mentions, direct messages and slash commands still work. Enable the intent in the Developer Portal and request it in code.

What does a 429 error from Discord mean?

A rate limit: the bot sent requests faster than allowed and must wait retry_after seconds. The libraries do that for you. If you see failures on every request, the bot's IP may be temporarily blocked after 10,000 responses with status 401, 403 or 429 in 10 minutes.

Why did my bot token stop working?

Either the token was reset in the Developer Portal, or Discord reset it after the bot started 1,000 gateway sessions in 24 hours, which usually means a crash loop. Reset it on the Bot page, put the new token in the bot's environment, and add a restart delay.

How much does bot hosting cost at Puranode?

Hobby is €4.99 a month for one bot on 0.5 vCPU and 512 MB of RAM, with auto-restart on crash. Standard is €9.99 for up to three bots on 1 vCPU and 1 GB. Prices include VAT.

Projects referenced

This guide names other people’s work. These are their own pages, so you get the current documentation rather than our summary of it.

  • Discord Gateway documentation — Heartbeats and zombied connections, the 1,000 identify limit and token reset, the 120 events per 60 seconds send limit, and the privileged intent rules.
  • Discord opcodes and status codes — The gateway close codes the guide lists, and which of them Discord marks as not reconnectable.
  • Discord rate limits — The 50 requests per second global limit, 429 responses and retry_after, X-RateLimit-Scope, and the 10,000 invalid requests per 10 minutes that trigger a temporary IP block.
  • Discord developer quick start — Where Reset Token lives, that a token is shown only once, and never committing it to version control.
  • discord.py — run() and its reconnect behaviour, on_disconnect and on_resumed, on_error, LoginFailure, PrivilegedIntentsRequired, max_messages and max_ratelimit_timeout.
  • discord.py source — The exact log lines the guide quotes: the heartbeat blocked warning, the rate limit warning and the Improper token message.
  • discord.js Guide: common errors — The invalid token error, automatic WebSocket reconnects, and logging unhandled rejections.
  • discord.js Guide: cache customization — makeCache and sweepers for bounding memory in a discord.js bot.
  • discord.js — The shardDisconnect, shardReconnecting and shardResume events, the Used disallowed intents error, and the REST rateLimited and invalidRequestWarning events.
  • Node.js events: error events — An emitted 'error' with no listener throws and exits the process.
  • Node.js command-line options — --unhandled-rejections, whose default since Node 15 turns an unhandled rejection into an uncaught exception, and --max-old-space-size.
  • systemd.service — Restart=, and RestartSteps with RestartMaxDelaySec for growing restart delays.
  • PM2 restart strategies — Default auto-restart, exponential backoff capped at 15 seconds, and max_memory_restart checked every 30 seconds.
  • PM2 startup — pm2 startup and pm2 save, which bring a Node bot back after a reboot.
  • Docker restart policies — The no, on-failure, always and unless-stopped policies, and the 10 second rule before a policy applies.
  • Docker resource constraints — The --memory limit and the kernel killing processes in a container that runs out of memory.

Related guides

How Much RAM Does a Minecraft Server Need?

Size a Minecraft server heap by player count and modpack weight, learn to read MSPT and GC, and find out when more RAM genuinely will not help.

Read the guide

Paper vs Forge vs Fabric for a Minecraft Server

Paper runs plugins; Forge, NeoForge and Fabric run mods. Which to pick, which Java you need, what 26.1 changed, and how to move a world.

Read the guide

Minecraft Server Lagging? How to Diagnose and Fix TPS

Your Minecraft server lags: is it TPS, ping or client FPS? Diagnose the right one in 60 seconds, then fix it with settings changes that cost nothing.

Read the guide

How to Host a Rust Server: Wipes, Oxide, Map Seeds

A working guide to hosting Rust: force wipe mechanics and the exact files to delete, Oxide vs Carbon, worldsize versus RAM, and a first-wipe checklist.

Read the guide

Self-Hosting vs Renting a Game Server: Honest Costs

Real numbers on self-hosting versus renting a game server: upload per player, CGNAT, DDoS exposure, watts, uptime, and when self-hosting wins.

Read the guide

How to Commission a Custom Minecraft Plugin

When a custom Minecraft plugin is worth paying for, how to write a brief that gets a fixed price, a worked Varo example, and what to own at handover.

Read the guide

How to Host a Discord Bot 24/7 Without a Laptop

Keep a Discord or Telegram bot online 24/7: supervised restarts, gateway reconnects, intents, token leaks, honest sizing, backups and safe AI API calls.

Read the guide

How to Set Up a CS2 Server With Plugins

Set up a Counter-Strike 2 dedicated server: disk and RAM it really needs, the Steam login token, Metamod:Source, CounterStrikeSharp and Workshop maps.

Read the guide

CS:GO Server Hosting in 2026: Move to CS2?

Looking for CS:GO server hosting? What changed when CS2 replaced CS:GO, what still works, and how to move a community, retake or practice server across.

Read the guide

Valheim Dedicated Server: Mods, RAM and Cost

Run a Valheim dedicated server with BepInEx mods: how much RAM it needs, which mods go on the server, crossplay, world backups and what it costs to rent.

Read the guide

How Much Does an ARK Ascended Server Cost?

What an ARK: Survival Ascended server costs to rent and why: RAM per map, why player slots are not the price, clusters, mods and what to check before you pay.

Read the guide

How Game Server Hosting Works at Puranode

What happens from the moment you ask for a game server to the moment friends join: setup, the control panel, mods, billing and what the price includes.

Read the guide

How Custom Plugin Development Works: Brief to Build

How commissioning a custom plugin or mod works at Puranode: the brief, the fixed quote, building and testing, delivery, and what you own at the end.

Read the guide

How AI Agent and Bot Hosting Works at Puranode

How hosting a Discord bot, Telegram bot or AI agent works: deploying your code, keeping API keys out of it, automatic restarts, storage and plans.

Read the guide

How Puranode Web Hosting Works: Containers, SSL, Domains

How website hosting in an isolated container works: what you get on day one, the free subdomain and SSL, uploading a site, and pointing your own domain.

Read the guide

How the Trading Bot Builder Works: Backtest to Export

How the Puranode trading bot builder works: setting rules, backtesting on real hourly candles in your browser, and exporting Python and TradingView code.

Read the guide

Enshrouded 1.0 Dedicated Server Setup Guide

Set up an Enshrouded 1.0 dedicated server: the RAM and port it needs, enshrouded_server.json explained, moving your world and launch day updates.

Read the guide

Palworld Dedicated Server Setup: RAM and Ports

Set up a Palworld dedicated server: Pocketpair's RAM and CPU figures, UDP port 8211, PalWorldSettings.ini, the REST API, moving saves and restarts.

Read the guide

Terraria Server Setup: TShock or tModLoader

Set up a Terraria dedicated server: vanilla, TShock or tModLoader, RAM by world size, port 7777, serverconfig.txt, moving a world and backups.

Read the guide

Satisfactory Dedicated Server Setup and Ports

Set up a Satisfactory dedicated server: ports 7777 and 8888 explained, RAM and CPU by factory size, claiming it, uploading a save, autosaves and updates.

Read the guide

Project Zomboid Dedicated Server Setup Guide

Set up a Project Zomboid dedicated server on Build 42: the two UDP ports, Java memory, servertest.ini, admin, Workshop mods, saves and wipes.

Read the guide

7 Days to Die Dedicated Server Setup Guide

Set up a 7 Days to Die dedicated server on V3: ports 26900 to 26903, serverconfig.xml and SandboxCode, world choice, admins, telnet, EAC and updates.

Read the guide

How to Make a Minecraft Server for Friends

Make a Minecraft server for friends: LAN, Realms, self-hosting or renting, Java 25, the EULA, port 25565, CGNAT, whitelists, Bedrock crossplay and backups.

Read the guide

Minecraft Can't Connect to Server? Fixes by Error

Minecraft can't connect to server? Fixes by exact error: Connection timed out, Connection refused, Incompatible client, Failed to verify username.

Read the guide

Garry's Mod Dedicated Server Setup, Step by Step

Set up a Garry's Mod dedicated server: SteamCMD app 4020, ports, the app 4000 login token, server.cfg, DarkRP and TTT, Workshop collections and ULX.

Read the guide

Keep the bot online without your laptop

Hobby runs one bot on 0.5 vCPU and 512 MB, with auto-restart on crash, for €4.99 a month. Standard runs up to three bots on 1 GB for €9.99. VAT included.