Common Discord bot errors and how to fix them
Fixes for the Discord bot errors we see most: invalid token, privileged intents, ModuleNotFoundError and npm errors, wrong Python or Node.js version, port already in use, and a bot that is online but not responding.
Start your server, open the Console and read the last few lines when it fails. Find the matching error below. For crashes, memory and disk problems, see Troubleshooting.
Faster: in the ESN Systems Discord, run /botfix and paste your error. ESN Helper replies with the usual fix and the right section of this page. Remove your bot token from the paste first.
Invalid token #
You'll see LoginFailure: Improper token has been passed (Python), TokenInvalid or An invalid token was provided (Node.js), or 401 Unauthorized.
- Get a fresh token: Developer Portal → your app → Bot → Reset Token. Resetting makes the old one stop working.
- Paste it into
.envasDISCORD_TOKEN=...with no quotes, spaces or extra lines. - Check the file is named exactly
.env(notenv.txt) and sits in the top folder. - Check your code loads it:
load_dotenv()in Python orrequire("dotenv").config()in Node.js, before the token is used. If the token comes back empty, the bot can't log in.
Setup steps: Add your token safely.
Privileged intents not enabled #
You'll see PrivilegedIntentsRequired (Python) or Used disallowed intents (Node.js).
- Open the Discord Developer Portal → your app → Bot.
- Under Privileged Gateway Intents, turn on the ones your code asks for: Presence, Server Members and/or Message Content. Save.
- Restart your server.
If you don't need an intent, remove it from your code instead. Bots in 100 or more servers need Discord's approval for these intents.
ModuleNotFoundError, "Cannot find module" or npm errors #
- Python
ModuleNotFoundError: No module named 'x': add the package torequirements.txtand restart. The import name isn't always the package name:dotenvispython-dotenv,PILisPillow,yamlisPyYAML, anddiscordisdiscord.py. - Node.js
Cannot find module 'x': add it todependenciesinpackage.json(runnpm install xon your computer and upload the newpackage.json), then restart. If the missing module is your own file, check the path and capitals. npm: not foundornode: not found: your bot is JavaScript but the server is set up for Python (or the other way round). Switch the server type. On an older free Nano, use the Bot type menu on your dashboard. Otherwise, open a ticket.npm ERR!while installing: read the lines just above it. Usually a package name or version inpackage.jsonis wrong, or a package needs a newer Node.js (see the next section).- Make sure
requirements.txtorpackage.jsonis in the top folder. If it's inside a subfolder, nothing gets installed.
Wrong Python or Node.js version #
Pick the version on the Startup page in the Docker Image box: Python 3.12 or 3.13, or Node.js 22 or 24. Restart after changing it.
No module named 'audioop'on Python 3.13: older discord.py versions need a module that Python 3.13 removed. Update to the latestdiscord.pyin requirements.txt, or choose Python 3.12.SyntaxErroron code that works on your computer: check which Python version you use at home (python --version) and pick the same or newer.- Node.js packages that say
Unsupported enginewant a different Node.js version. Choose the one their docs name.
Port already in use #
You'll see OSError: [Errno 98] Address already in use (Python) or EADDRINUSE (Node.js).
- Most Discord bots don't need a port at all. If you copied a "keep alive" web server from Replit or a tutorial, remove it. Your ESN server stays on by itself.
- If your bot really runs a website or webhook, use your server's own port. You'll find it on the Network page, and your code can read it from the
SERVER_PORTenvironment variable. Listen on0.0.0.0. - Check your code doesn't start the web server twice, for example in two files.
Bot is online but doesn't respond #
- Prefix commands like
!helpdon't work: the bot can't read messages without the Message Content intent. Turn it on in the Developer Portal (see above) and in your code:intents.message_content = Truein discord.py, orGatewayIntentBits.MessageContentin discord.js. Restart. - Slash commands don't show up: invite the bot with the
applications.commandsscope, and make sure your code registers (syncs) its commands when it starts. New global commands can take a while to appear; restarting Discord helps. - Nothing happens in one channel: the bot needs permission to view and send messages there. Check the channel's permissions for the bot's role.
- The bot replies twice: another copy is running with the same token, often on your computer or an old host. Stop the other copy, or reset the token so only the ESN server has it.
More guides: Discord slash commands not showing up? How to register and sync them, Discord privileged intents explained: message content, members and presence, Why is my Discord bot offline? Causes and fixes.
Still stuck? Use the live chat on the panel or ask in the ESN Systems Discord. Last updated October 31, 2026.