NodeOps
UK

Guide

How to Deploy a Discord Bot That Stays Online 24/7

Deploy your bot as a persistent process on a cloud platform. The bot connects to Discord's gateway on startup and stays connected. Use a CLI to deploy in one command, set your bot token as an environment variable, and the bot stays online permanently.

The problem

Your Discord bot runs on your laptop. It goes offline when you close the terminal, when your computer sleeps, or when your WiFi drops. Running a bot 24/7 on your machine is not sustainable. You need it deployed somewhere that stays online permanently.

Why your bot goes offline

Discord bots maintain a WebSocket connection to Discord's gateway. When your process stops, whether from closing the terminal, your computer sleeping, or a crash, the connection drops and the bot goes offline. Cloud deployment solves this by running your bot as a managed process that automatically restarts on failure.

What a bot deployment needs

A Discord bot needs: a persistent process (not serverless, since the bot must maintain a WebSocket connection), environment variables for the bot token, automatic restart on crash, and log access for debugging. Memory requirements are low, typically 128MB-256MB for most bots.

Slash commands vs gateway bots

Interaction-only bots (slash commands, buttons) can use Discord's HTTP interactions endpoint, which works with serverless. Gateway bots that listen for messages, reactions, presence changes, or voice events need a persistent WebSocket connection and must be deployed as a long-running process.

Approaches compared

Platform CLI (CreateOS, Railway, Fly)

Pros

  • One-command deploy
  • Persistent process support
  • Auto-restart on crash
  • Environment variables for bot token
  • Log streaming

Cons

  • Monthly cost (usually $5-10/mo for small bots)

Best for: Developers who want their bot online without managing servers

VPS (DigitalOcean, Hetzner, Oracle free tier)

Pros

  • Cheap or free (Oracle free tier)
  • Full control
  • Can run multiple bots

Cons

  • Manual setup (systemd, pm2)
  • Manual updates and restarts
  • No built-in log management

Best for: Budget-conscious developers comfortable with Linux

Raspberry Pi / Home server

Pros

  • No monthly cost after hardware
  • Full control

Cons

  • Depends on your home internet
  • Power outages take bot offline
  • Dynamic IP issues

Best for: Small personal bots, hobby projects

Deploy a Discord bot with CreateOS CLI

Here is how to do it step by step using CreateOS CLI.

1

Install the CLI

$ brew install createos

Single binary for macOS and Linux.

2

Deploy your bot

$ createos login && createos init && createos deploy

The CLI auto-detects your Node.js or Python project and deploys it as a persistent process.

3

Set the bot token

$ createos env set DISCORD_TOKEN=your-bot-token-here

Store your bot token securely as an environment variable. Never commit it to git.

4

Check logs

$ createos deployments logs -f

Stream bot logs in real time. See connection status, command usage, and errors.

5

Schedule maintenance tasks

$ createos cronjobs create --name cleanup-temp-channels --schedule "0 0 * * *" --path /api/cleanup

Run scheduled tasks like cleaning temporary channels, updating leaderboards, or generating daily reports.

Frequently asked questions

Will my Discord bot stay online 24/7?
Yes. Cloud platforms run your bot as a persistent process that automatically restarts if it crashes. Unlike running on your laptop, the bot does not go offline when you close your terminal or when your computer sleeps.
How much does it cost to host a Discord bot?
Small bots (under 100 servers) typically cost $3-7 per month on a cloud platform. Larger bots may need more memory and cost $10-20 per month. Oracle Cloud and some platforms offer free tiers that work for very small bots.
Can I deploy a bot written in any language?
Yes. Discord bots can be written in JavaScript (discord.js), Python (discord.py, Pycord), Java (JDA), Go (discordgo), Rust (serenity), or any language with a Discord library. If it runs as a process, it can be deployed.
How do I update my bot after deploying?
Push your code changes and run createos deploy again. The CLI builds and deploys the new version. The old process is replaced with zero downtime for short deployments. For GitHub-connected projects, deploying is automatic on every push.

Try it yourself

$ brew install createos

100,000+ Builders. One Workspace.

Get product updates, builder stories, and early access to features that help you ship faster.

CreateOS is a unified intelligent workspace where ideas move seamlessly from concept to live deployment, eliminating context-switching across tools, infrastructure, and workflows with the opportunity to monetize ideas immediately on the CreateOS Marketplace.