Bot Uptime

How to Fix the 10 Most Common Discord Bot Errors (DisallowedIntents, 401, 429 & More)

Every Discord bot developer runs into cryptic gateway close codes and REST error numbers sooner or later. Bookmark this troubleshooting guide to diagnose and fix the ten most frequent production errors in under two minutes.

1. Error: Used Disallowed Intents (Gateway Close Code 4014)

This is the #1 error for new deployments. Your code requested a Privileged Gateway Intent (GuildMembers, GuildPresences, or MessageContent), but that toggle is turned OFF in your Discord Developer Portal.

Fix: Open discord.com/developers/applications → select your app → Bot → scroll down to Privileged Gateway Intents → enable the matching toggles → click Save Changes → restart your bot container.

2. Error: 401 Unauthorized / Improper Token Has Been Passed

Discord rejected your bot token. Common causes include pasting your Application Client Secret instead of the Bot Token, trailing whitespace/quotes inside your .env file, or Discord automatically revoking your token because it was accidentally pushed to a public GitHub repo.

Fix: Reset your Bot Token in the Developer Portal, paste the fresh token cleanly with no extra spaces or quotes into .env, save, and restart.

3. Error 10062: Unknown Interaction ("This interaction failed")

Discord requires every slash command, button click, or modal submit to receive an initial acknowledgment within exactly 3 seconds. If your bot queries a slow external API or database before replying, the interaction token expires and throws error 10062.

Fix: Always call deferReply() (or interaction.response.defer() in discord.py) immediately at the top of any command that takes more than 500ms, then follow up with editReply() once your work finishes.

4. Error 50013 (Missing Permissions) & 50001 (Missing Access)

Error 50001 means the bot cannot even view the target channel; Error 50013 means it can see the channel, but lacks a specific permission (like Manage Roles, Ban Members, or Embed Links) OR the target user has a role positioned HIGHER than the bot role.

Fix: Open Server Settings → Roles and drag your bot’s role ABOVE the roles it needs to assign or moderate. Discord strictly enforces role hierarchy even when a bot has Administrator off or Manage Roles on.

5. HTTP 429 Too Many Requests & Gateway Disconnects (ECONNRESET)

If your bot edits messages every 1 second (like a live countdown timer) or spams channel renames, Discord will rate-limit your route or temporarily block your IP.

Fix: Never edit channel names more than twice per 10 minutes (Discord enforces a strict 2/10m channel-rename bucket), batch status updates, and use Discord timestamps like <t:1764600000:R> instead of editing countdown messages every second!

  • Use <t:UNIX_SECONDS:R> for zero-API-call live countdown timers inside Discord.
  • Cache read-only guild configs in memory instead of calling fetch() on every single message.
  • Wrap DM sends in try/catch — Error 50007 simply means the recipient disabled Server DMs.

Frequently Asked Questions

What does Error 50007 "Cannot send messages to this user" mean?

It is not a bug in your bot — the target Discord user has turned off Direct Messages from server members or blocked the bot. Always catch error 50007 gracefully.

Why does my bot restart with Exit Code 137?

Exit code 137 means the Linux kernel OOM-killed the container because the process exceeded its RAM limit. Check for memory leaks (growing arrays/maps) or upgrade your plan RAM.

Ready to deploy your bot 24/7?

Launch a custom Discord, Telegram, or WhatsApp container (Python, Node.js, Java, Rust) with Managed Databases and Free AI Agents — or deploy a ready-made Discord bot in 1 click on Bot Uptime.