Invalid Token
Discord refused to log your bot in because the token it received is wrong, missing, or has been reset.
What You See
Node.js (discord.js)
Error [TokenInvalid]: An invalid token was provided.
# Older versions: [TOKEN_INVALID] An invalid token was provided.
Python (discord.py)
discord.errors.LoginFailure: Improper token has been passed.
# or, if the variable is empty:
TypeError: expected token to be a str, received NoneType instead
Common Causes
| Cause | How to check |
|---|---|
The .env file isn't loaded | Print whether the variable exists (see below) |
| The variable name doesn't match | DISCORD_TOKEN in .env but process.env.TOKEN in your code |
| Extra characters | Spaces, quotes or a line break around the value |
| The token was reset | Discord resets a token when you click "Reset Token" — or automatically when it is leaked publicly |
| Wrong value copied | The Client Secret or Application ID is not the bot token |
Check the Token Is Loaded
Add this temporarily at the top of your entry file, restart, and read the console. It shows whether the token is there without printing it:
Node.js
require('dotenv').config();
console.log('Token loaded:', Boolean(process.env.DISCORD_TOKEN),
'| length:', process.env.DISCORD_TOKEN?.length);
Python
import os
from dotenv import load_dotenv
load_dotenv()
token = os.getenv("DISCORD_TOKEN")
print("Token loaded:", token is not None, "| length:", len(token or ""))
false/None: the.envfile isn't at the root of the server, isn't named exactly.env, ordotenvisn't called before you read the variable. See Environment Variables.- Loaded but rejected: the value itself is wrong — get a new token.
Get a New Token
- Open the Discord Developer Portal and select your application
- Go to the "Bot" page
- Click "Reset Token" and copy the new value
- Paste it in your
.envfile, with no quotes and no spaces:
.env
DISCORD_TOKEN=MTExMTExMTExMTExMTExMTEx.XXXX.XXXXXXXX
- Save the file and restart the server
Reset a Leaked Token
If your token ever appeared in a public place (GitHub repository, screenshot, Discord message), consider it compromised: anyone can control your bot with it.
- Reset it immediately on the Developer Portal (steps above)
- Update your
.envfile on KataBump and restart - Remove it from your code and add
.envto your.gitignore
Security
Never paste your token in your code, in a support ticket, or in a public channel. The KataBump team will never ask for it.
Token OK but the bot still won't connect?
If the error now mentions intents, go to Disallowed Intents.