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

CauseHow to check
The .env file isn't loadedPrint whether the variable exists (see below)
The variable name doesn't matchDISCORD_TOKEN in .env but process.env.TOKEN in your code
Extra charactersSpaces, quotes or a line break around the value
The token was resetDiscord resets a token when you click "Reset Token" — or automatically when it is leaked publicly
Wrong value copiedThe 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 .env file isn't at the root of the server, isn't named exactly .env, or dotenv isn'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

  1. Open the Discord Developer Portal and select your application
  2. Go to the "Bot" page
  3. Click "Reset Token" and copy the new value
  4. Paste it in your .env file, with no quotes and no spaces:
.env
DISCORD_TOKEN=MTExMTExMTExMTExMTExMTEx.XXXX.XXXXXXXX
  1. 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.

  1. Reset it immediately on the Developer Portal (steps above)
  2. Update your .env file on KataBump and restart
  3. Remove it from your code and add .env to 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.

Esc
Type to search the docs…