Some links here are affiliate links — if you buy through them we may earn a commission at no extra cost to you. It never changes what we recommend. Full disclosure.
Disclosure: This article contains affiliate links. If you sign up through them, we may earn a commission at no extra cost to you — thanks for supporting the site.
This is the exact walkthrough I give every co-moderator who wants to move a bot off free hosting for the first time. It's less intimidating than it sounds — most of the "work" is just a handful of commands run once.
Why This Matters
The biggest barrier to self-hosting a bot usually isn't technical difficulty — it's not knowing the order of steps. Once you've done it once, it's genuinely a 20-minute process for a simple bot, and every future bot you deploy will be faster because the pattern repeats.
What you actually need before starting:
- Your bot's code, ready to run locally already
- Your bot token, kept out of the codebase itself
- A Droplet, sized modestly — most community bots don't need much horsepower
A Simple Framework
- Create a Droplet with a standard Linux image — a small size is fine to start
- SSH into the Droplet and install the runtime your bot needs (Node.js, Python, etc.)
- Transfer your bot's code to the Droplet, keeping secrets in environment variables, not in the code itself
- Install a process manager (like
pm2for Node or asystemdservice for anything else) so the bot restarts automatically if it crashes - Start the bot and confirm it comes online in your server, then test that it survives a manual reboot of the Droplet
Example
Before: A bot runs directly in a terminal session on someone's laptop. The moment that laptop closes or loses internet, the bot goes offline — a genuinely common failure mode for early-stage community bots.
After: The same bot runs as a managed process on a Droplet, started automatically via a process manager. It stays online continuously, survives a server reboot without manual intervention, and doesn't depend on anyone's personal laptop staying open.
> Tip: Test what happens when you reboot the Droplet before you consider the deployment "done." If the bot doesn't come back online automatically after a reboot, your process manager isn't configured correctly yet — better to find that out now than during an actual server restart.
Common Mistakes
- Running the bot in a raw terminal session instead of a process manager
- Committing the bot token directly into source code or a public repository
- Skipping the reboot test, only to discover the bot doesn't auto-start after a real restart
- Oversizing the Droplet for a bot that genuinely doesn't need much compute
DigitalOcean's Droplets documentation covers creating and connecting to your first Droplet, which is the starting point for this whole walkthrough.
> (ad) I run every community bot I maintain on a small DigitalOcean Droplet — cheap enough that cost is a non-issue, and reliable enough that I stopped thinking about it.
Twenty minutes now saves you from the far more stressful version of this task — migrating a bot in a panic after a free host finally gives out for good.