Discord bot offline: the causes and how to fix them
Rejected token, disallowed intents, crashes, DNS, rate limits or sleep mode: how to read your Discord bot's error and bring it back online.
A Discord bot goes offline for five main reasons: the program stopped, the token is rejected, an intent is not allowed, the network can no longer reach Discord, or the host put the bot to sleep. Your bot's console almost always tells you which one. Here is how to read that message and fix each case.
- Read the first error in the console: the ones after it are often a consequence.
- A 401 or 4004 error means the token was rejected: generate a new one with Reset Token.
- Code 4014 means a privileged intent must be enabled in the Developer Portal.
- Exit code 137 usually means the bot ran out of memory.
Read the first error
Before changing the code, open the console or the logs and scroll back to the first error shown after startup. The lines after it are often a consequence. Also note the time it stopped: a stop at a fixed time has a different cause from a stop on the first message.
- The bot does not start at all: dependency, file or version.
- The bot starts, then disconnects: token, intents or network.
- The bot stays connected but stops responding: an error in a command or a rate limit.
Token rejected or reset
A 401 error or close code 4004 (Authentication failed) means Discord rejects the token. It may have been reset from the Developer Portal, or by Discord itself if it was published, for example in a public GitHub repository. Generate a new token with Reset Token, replace it in the DISCORD_TOKEN variable, then restart.
- Copy the token from the Bot page, not the application ID or the client secret.
- Remove any spaces and quotes around the value.
- Keep the token out of the code, as explained in the guide to storing tokens and secret variables.
Disallowed intents
Close code 4014 (Disallowed intent(s)) appears when the code requests a privileged intent that is not enabled in the Developer Portal: Message Content, Server Members or Presence. Enable it in the Bot tab, or remove it from the code if the bot does not need it. Beyond 100 servers, these intents also require approval from Discord.
- discord.py: intents.message_content = True must match the portal setting.
- discord.js: GatewayIntentBits.MessageContent follows the same rule.
- Slash commands work without Message Content.
Crashes, memory and dependencies
When the program stops, the bot goes down with it. Cannot find module or ModuleNotFoundError points to a dependency missing from package.json or requirements.txt. An exit with code 137 usually means the bot ran out of memory: a cache that is too large, a leak or audio playback. An unhandled exception in an event can also stop the process.
- Step-by-step fixes: Node.js module not found and Python module not found.
- Out of memory: the guide to exit code 137.
- Wrap each command in a try/catch (Node.js) or a try/except (Python) that writes the error to the logs.
Network, DNS and rate limits
getaddrinfo EAI_AGAIN or ECONNRESET points to a DNS or network outage between the bot and Discord. discord.js and discord.py reconnect to the gateway on their own; if the error keeps coming back, note the time and send it to your host. A 429 response means a rate limit: the bot is making too many calls, often in a loop. Discord also temporarily blocks an IP address that sends too many invalid requests, 10,000 in 10 minutes, for example with a rejected token.
- Do not restart the bot in a loop with an invalid token: each attempt counts as an invalid request.
- Let the library handle 429 responses: discord.js and discord.py wait for the delay Discord specifies.
- Avoid changing the roles or messages of many members in a single loop.
Sleep mode and due dates
Some free hosts stop an idle bot or stop it after a quota of hours: check your plan's terms. On the ACLClouds Free plan, the bot is not put to sleep. It only stops if the free 4-day renewal is not done. The next expiry date is shown on the service card.
- A bot hosted at home also stops when your PC or your router does.
- For continuous uptime, follow our guide to hosting a Discord bot 24/7.
Why choose ACLClouds for this bot
The panel helps you fix the most common failures without leaving the browser. When the token is missing, the console shows a card where you paste it and restart the bot. When the start file cannot be found, it searches the sub-folders and offers to fix the path in one click. A bot that stops unexpectedly restarts automatically.
- Live console and logs in the panel, free plan included.
- SFTP access for each bot (port 2222), free plan included.
- Free plan without sleep mode, renewable for free every 4 days: follow the Python and Node.js tutorial.
Frequently asked questions
Why is my bot offline when the code has not changed?
Most often, the token was reset, the hosting reached its due date or the network can no longer reach Discord. The first error in the console tells you which.
What does error 4014 mean?
The bot requests a privileged intent (Message Content, Server Members or Presence) that is not enabled in the Bot tab of the Developer Portal. Enable it or remove it from the code.
How do I know if my token leaked?
A sudden 401 or 4004 error, without any change on your side, is the usual sign. Generate a new token with Reset Token and check that it does not appear in any public repository.
My bot is online but does not respond: what should I check?
Check that slash commands are synced, that the bot has the channel permissions and that the Message Content intent is enabled for prefix commands. Then read the errors shown for each command.