Skip to content

Discord Bot Troubleshooting

Reference this guide when customers report Discord bot issues. Common symptoms, causes, and resolutions are organized by category.

SymptomPossible CauseResolution
”Websocket connecting…” stuckInvalid tokenRegenerate token in Discord Developer Portal, update env var
”Disallowed intents” errorPrivileged intents not enabledEnable MESSAGE_CONTENT, GUILD_MEMBERS intents in Developer Portal
Bot exits immediately (code 0)Missing DISCORD_TOKEN env varVerify environment variable is set and not empty
”Invalid token” errorToken regenerated elsewhereGet fresh token from Developer Portal
Bot offline in DiscordContainer not runningCheck portal status, review startup logs
  1. Verify token format (starts with bot user ID encoded in base64)
  2. Ensure no extra whitespace in environment variable
  3. Confirm token hasn’t been regenerated since last deployment
  4. Check token isn’t from wrong bot application

Required intents depend on bot functionality:

FeatureRequired IntentPrivileged
Message contentMESSAGE_CONTENTYes
Member eventsGUILD_MEMBERSYes
Presence updatesGUILD_PRESENCESYes
Basic commandsGUILDSNo
ReactionsGUILD_MESSAGE_REACTIONSNo

Enable privileged intents at: Discord Developer Portal → Bot → Privileged Gateway Intents

Symptoms:

  • Bot becomes unresponsive
  • “Heap out of memory” errors
  • Frequent restarts

Solutions:

  1. Reduce Discord.js cache sizes
  2. Implement data pagination
  3. Clear unused variables
  4. Upgrade to larger plan
  5. Use external caching (Redis)

Cache configuration example:

const client = new Client({
intents: [...],
makeCache: Options.cacheWithLimits({
MessageManager: 25,
GuildMemberManager: 50,
PresenceManager: 0
})
});

Symptoms:

  • Slow command responses
  • Timeouts
  • High resource usage in portal

Solutions:

  1. Profile code to find bottlenecks
  2. Offload heavy operations to workers
  3. Implement request queuing
  4. Cache expensive computations
  5. Upgrade plan for more CPU

Symptoms:

  • “Interaction failed” messages
  • Commands timing out
  • Users reporting lag

Solutions:

  1. Use deferReply() for operations > 3 seconds
  2. Cache database queries
  3. Optimize API calls
  4. Implement pagination for large responses

Defer example:

await interaction.deferReply();
// ... long operation ...
await interaction.editReply('Done!');
IssueCauseFix
Commands not appearingNot registeredRun registration script with correct token
Wrong server shows commandsGuild vs global registrationCheck registration scope
Old commands persistCache delayWait up to 1 hour for global, restart Discord app
”Unknown interaction”Handler not implementedAdd interaction handler for command
const { REST, Routes } = require('discord.js');
const rest = new REST().setToken(process.env.DISCORD_TOKEN);
// Global commands (up to 1 hour delay)
await rest.put(Routes.applicationCommands(clientId), { body: commands });
// Guild commands (instant, for testing)
await rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands });

Symptoms:

  • No audio playback
  • Voice connection drops
  • “FFMPEG not found” errors

Solutions:

  1. Verify FFmpeg installed:

    • Check with support if system package is available
    • Some nodes include FFmpeg by default
  2. Check permissions:

    • Bot needs CONNECT and SPEAK in voice channel
    • Verify role hierarchy allows joining
  3. Voice adapter setup:

    const { joinVoiceChannel } = require('@discordjs/voice');
    const connection = joinVoiceChannel({
    channelId: channel.id,
    guildId: guild.id,
    adapterCreator: guild.voiceAdapterCreator
    });
  4. Consider Lavalink: For production music bots, external audio servers reduce load

ErrorCauseFix
”Cannot find module”Dependencies not installedRun npm install
”Module not found”Wrong import pathCheck file exists at path
node-gyp errorsNative module build failedUse pre-built binaries or request build tools
Version mismatchPackage incompatibilityCheck package.json engines, update packages
ErrorCauseFix
”ModuleNotFoundError”Package not installedRun pip install -r requirements.txt
”No module named”Import path wrongCheck package name vs import name
Wheel build failedMissing system librariesRequest library installation or use pre-built wheels

Symptoms:

  • 429 errors in logs
  • Commands failing intermittently
  • “You are being rate limited” messages

Solutions:

  1. Implement request queuing
  2. Respect X-RateLimit headers
  3. Cache frequently accessed data
  4. Use bulk operations where possible
  5. Add exponential backoff

Rate limit handling:

client.rest.on('rateLimited', (info) => {
console.log(`Rate limited: ${info.route} for ${info.timeout}ms`);
});
ErrorCauseFix
”Connection refused”Wrong host/portVerify DATABASE_URL env var
”Access denied”Wrong credentialsCheck username/password
”Too many connections”Pool exhaustedImplement connection pooling
”Connection timeout”Network issueCheck if database service is running

Prevention:

  • Enable WAL mode
  • Schedule graceful restarts
  • Regular backups

Recovery:

  1. Stop the bot
  2. Restore from backup
  3. Run integrity check: PRAGMA integrity_check;

Symptoms:

  • Bot continuously restarting
  • “Maximum restart attempts reached”
  • Rapid console clear/start cycles

Diagnosis:

  1. Check console for error message before restart
  2. Note the exit code:
    • Code 0: Clean exit, check if bot completes and exits
    • Code 1: Error, check stack trace
    • Code 137: Out of memory (OOM killed)

Solutions:

  1. Fix the underlying error in code
  2. Increase memory if OOM
  3. Disable problematic features via env vars
  4. Rollback to last working backup
Terminal window
node --version
Terminal window
npm list
Terminal window
node -e "console.log(process.memoryUsage())"
Terminal window
python --version
Terminal window
pip list

Escalate to hosting support when:

  • Suspected infrastructure issues (network, disk, hardware)
  • Need system packages installed (FFmpeg, codecs)
  • Persistent issues after troubleshooting
  • Security concerns
  • Billing or account issues
1. Bot/Server name and ID
2. Timeline of when issue started
3. Recent changes (code, config, updates)
4. Full console output/logs
5. Steps already taken to troubleshoot
6. Steps to reproduce (if known)