Nothing is more frustrating than a Discord bot that keeps going offline. Users complain, features break, and you spend hours debugging. This guide covers the most common causes and how to fix them.
Your bot runs out of RAM and crashes.
Symptoms:
Causes:
Solutions:
Increase memory limit for Node.js:
node --max-old-space-size=1024 index.js
Limit cache sizes:
const client = new Client({
makeCache: Options.cacheWithLimits({
MessageManager: 50,
GuildMemberManager: 100,
}),
});
Uncaught exceptions crash your bot process.
Symptoms:
Solutions:
Add global error handlers:
process.on('unhandledRejection', (error) => {
console.error('Unhandled promise rejection:', error);
});
process.on('uncaughtException', (error) => {
console.error('Uncaught exception:', error);
});
client.on('error', (error) => {
console.error('Client error:', error);
});
Discord rate limits your bot for making too many requests.
Symptoms:
Solutions:
Your bot token is invalid or revoked.
Symptoms:
Solutions:
Connection problems between your server and Discord.
Symptoms:
Solutions:
Your hosting service has problems.
Symptoms:
Solutions:
Your hosting plan cannot handle the load.
Symptoms:
Solutions:
Always start with logs. They tell you exactly what went wrong.
// Add timestamps to logs
console.log(\`[\${new Date().toISOString()}] Bot started\`);
Track RAM and CPU usage:
setInterval(() => {
const used = process.memoryUsage();
console.log(\`Memory: \${Math.round(used.heapUsed / 1024 / 1024)}MB\`);
}, 60000);
If your bot works locally but not on hosting, the issue is likely:
Visit status.discord.com to see if Discord itself has issues.
PM2 automatically restarts your bot on crashes:
npm install pm2 -g
pm2 start index.js --name "my-bot"
pm2 save
Monitor your bot's status:
setInterval(() => {
if (!client.ws.ping) {
console.error('Bot appears disconnected');
process.exit(1); // Let PM2 restart
}
}, 30000);
Get notified when your bot goes offline:
When your bot goes offline, check these in order:
Consider upgrading if:
Usually resource limits. Local machines have more RAM than basic hosting plans.
Use a hosting service with good uptime guarantees and process managers like PM2.
Only if your bot is in 2500+ servers. Sharding adds complexity.
With proper code, restarts should not be necessary. If you need regular restarts, fix the underlying issues.
Most bot downtime comes from memory issues, unhandled errors, or insufficient resources. Implement proper error handling, monitor your resources, and choose reliable hosting to keep your bot online.
VexaNode provides reliable Discord bot hosting with automatic restarts, resource monitoring, and 99.9% uptime guarantee to keep your bot running smoothly.
Join thousands of satisfied users and experience the VexaNode difference today.
View Plans