Hosting a Discord bot 24/7 without downtime
ยท
Process manager, environment variables, logs and monitoring: the minimal architecture for a bot that never sleeps.
A bot that shuts down when you close your PC isn't a bot, it's a demo. Here's how to host it properly for real availability, 24 hours a day.
- Store the token in an environment variable, never in your code.
- Entrust the restart to a process manager with an increasing delay.
- Monitor gateway latency and command error rate.
- Store data on a persistent volume and back up the database every day.
A pinned runtime and secrets kept out of the code
The classic first incident: the bot token committed to GitHub, revoked by Discord in the middle of the night. Store it in an environment variable, pin the Node.js or Python version, and version an example file (.env.example) without the values.
- Never commit the token: environment variables only.
- Pin the runtime version (e.g. Node 22 LTS) for reproducible deployments.
- Document each required variable in a README.
- To choose the host, compare free Discord bot hosting plans.
A process manager that restarts intelligently
PM2, systemd or Docker with a restart policy: the tool matters less than the policy. Restart automatically on crash, but with an increasing delay (backoff) so you don't loop on a configuration error, and keep persistent logs to understand what happened.
- Configure automatic restart with exponential backoff.
- Keep logs outside the container to diagnose crashes.
- Add a health check: is the bot still responding to commands?
Monitor what really matters
Being online is not enough: a bot that is connected but no longer responds to interactions is broken. Monitor Discord gateway latency, command error rate and memory. A simple alert (webhook, email) is worth more than a dashboard nobody looks at.
- Monitor Discord gateway latency and command error rate.
- Alert on repeated disconnections and memory leaks.
- Keep 7 days of logs for post-incident analysis.
Separate data from code
As soon as the bot stores anything (levels, economy, moderation), that data must survive a redeployment. A SQLite database on a persistent volume is enough to start; PostgreSQL takes over as the bot grows, with regular backups in both cases. For a bot that stays online around the clock without keeping your PC on, see Discord bot hosting.
- Store data on a persistent volume, never in the image.
- Back up the database daily to external storage.
- Test restores before you need them.
- Apply the 3-2-1 rule to database backups.
Frequently asked questions
Do I need to leave my computer on?
No. The bot runs on ACLClouds infrastructure and stays online regardless of your computer or internet connection.
Which languages are supported?
Node.js, Bun, Python, C#, Go, Java, Rust and Lua environments are available, with MariaDB for projects that need a database.
Where should I store my bot token?
In the panel's startup variables. You change the configuration without publishing the token in your source code.
Does my bot restart automatically after a crash?
Yes. The process restarts automatically after an unexpected stop, and logs remain viewable live in the panel.