Token errors (4004)
Symptoms: Error [TokenInvalid]: An invalid token was provided. (discord.js), discord.errors.LoginFailure: Improper token has been passed. (discord.py), or InvalidTokenException (JDA).
Fix:
- Developer Portal → your app → Bot → Reset Token, then copy it.
- Paste it into the host's environment variable (for example
BOT_TOKEN). Watch for stray spaces, quotes or a line break. - Make sure your code reads that exact variable name, and that you didn't paste the client secret or application ID instead.
- Restart the bot.
If the token keeps getting reset by itself, it has probably leaked, often in a public GitHub repo. Discord can automatically reset tokens that show up in public repos. Remove it from the code, rotate it, and keep it only in environment variables (deploying from GitHub safely).
Intents errors (4014)
Privileged intents are Message Content, Server Members and Presence. Discord's docs say you must toggle each one for your app in the Developer Portal before you request it. Verified apps, which Discord requires once you're in 100+ servers, also need approval.
Fix:
- Developer Portal → Bot → turn on the intents your code asks for.
- Ask only for what you use in code:
- discord.js: new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] })
- discord.py: intents = discord.Intents.default(); intents.message_content = True
- JDA: JDABuilder.createDefault(token).enableIntents(GatewayIntent.MESSAGE_CONTENT)
- Restart.
Commands see empty message.content? That's the same intent: without Message Content, text is blank except in DMs and messages that mention the bot. Or switch to slash commands, which don't need it.
Other close codes you might see
| Code | Meaning | What to do |
|---|---|---|
| 4011 | Sharding required | Bot is in 2,500+ servers; shard it |
| 4013 | Invalid intent(s) | Your intents value is malformed; check the bitfield |
| 4014 | Disallowed intent(s) | Enable or remove the privileged intent |
| 4004 | Authentication failed | Fix the token |
Where discordbothost helps
On discordbothost you set the token as an environment variable in the portal, so it stays out of your files and your repo. The console shows the exact error and close code when the bot starts. Bots restart automatically after a crash. Repeated crashes pause restarts; check the console before starting again. Paid plans post a crash alert to your Discord.
Sources
https://discord.com/developers/docs/topics/opcodes-and-status-codes; https://discord.com/developers/docs/events/gateway (privileged intents). Checked .
Questions
What does Discord error 4004 mean?
Authentication failed: the token sent when the bot connected is incorrect. Reset the token in the Developer Portal, update it on your host, and restart.
What does error 4014 Disallowed intent(s) mean?
Your bot asked for a privileged intent (Message Content, Server Members or Presence) that isn't enabled for the app. Enable it under Bot → Privileged Gateway Intents, or stop requesting it. Apps in 100+ servers must be verified and approved for privileged intents.
Why is message.content empty in my bot?
Message Content is a privileged intent. Enable it in the Developer Portal and request it in your code; otherwise message text is empty except for messages that mention the bot or DMs.
Sources
Related
Why Does My Discord Bot Keep Going Offline?
7 common reasons a Discord bot goes offline (PC sleep, sleeping free hosts, crashes, memory, bad token, intents, rate limits) and how to fix each.
Updated · 4 min readRender Discord Bot Hosting: Free Limits and Setup
Can Render host a Discord bot? Choose a worker or HTTP service, understand free sleep limits, set build commands and move your bot safely.
Updated · 4 min readHow to Host a Discord Bot for Free (Step by Step)
Host a Discord bot 24/7 for free: create the bot, upload your discord.js, discord.py or JDA code to a free host, set the token, and keep it renewed.
Updated · 3 min read