Skip to content
Puranode

Guide

How to Host a Discord Bot 24/7 Without a Laptop

To keep a Discord bot online 24/7 you need a machine that stays on and a supervisor that restarts the bot when it crashes and when the machine reboots. Reconnecting to Discord's gateway after a network drop is already handled by discord.py and discord.js. Everything around that is yours to get right: restarting without spending Discord's daily login allowance, keeping tokens out of repositories, sizing memory from measurement, keeping data safe across restarts, and calling AI models without a request hanging for minutes. This guide covers each, with Telegram alongside.

Published

FAQ

Frequently asked

Can I host a Discord bot 24/7 for free?

Yes, if you own a machine that stays on. Run the bot under systemd, Docker with a restart policy, or pm2, make sure it starts at boot, and test a crash and a reboot. You pay in electricity and in your time when something breaks. Paid hosting buys someone else's machine and supervision, not a different kind of bot.

Why does my bot go offline for a few seconds and then come back?

Usually that is the gateway working as designed. Connections are resumed after network drops, missed heartbeat acknowledgements and Reconnect events, and discord.py and discord.js handle all of it. Brief gaps are normal; long ones deserve a look at the logs.

Why did Discord reset my bot token?

One documented cause is the identify limit. A bot that starts 1,000 new gateway sessions in 24 hours, usually by crash-looping after login, has every session terminated and its token reset, and the owner is emailed. If the bot was not restarting repeatedly, check whether the token was ever pushed anywhere public, since GitHub reports Discord bot tokens it finds in public repositories to Discord.

Do I need the Message Content intent?

Only if the bot reads the text of other people's messages, as prefix commands and keyword triggers do. Slash commands do not need it, and even without it a bot sees its own messages, direct messages and messages that mention it. With fewer than 10,000 users you enable it yourself in the Developer Portal; beyond that, continued access needs a review.

Why is my Python bot's console empty when it is clearly running?

Output buffering. When stdout is not an interactive terminal, Python block-buffers it, so print output waits in a buffer and is lost if the process is killed. Run python -u, set PYTHONUNBUFFERED, or log through the logging module, whose default handler writes to stderr.

How do I stop AI replies timing out on Discord?

Defer the interaction within 3 seconds, then edit the reply in when the model finishes; the interaction token stays valid for 15 minutes. Give the model call its own timeout in seconds, because SDK defaults can run to minutes, and use an async client so the wait never blocks the bot's heartbeats.

Projects referenced

This guide names other people’s work. These are their own pages, so you get the current documentation rather than our summary of it.

  • Discord Gateway documentation — The source for heartbeats and resuming, the 1,000 identify limit and the token reset that follows it, the 120 events per 60 seconds send limit, sharding at 2,500 servers, and the privileged intent rules, including the 10,000 user threshold and the Message Content exceptions.
  • Discord interactions: receiving and responding — The 3 second deadline for a first response, deferred responses, and the 15 minute interaction token that the AI section is built around.
  • Discord developer quick start — Where the Reset Token button lives, and Discord's own instruction never to check a bot token into version control.
  • Discord app verification — Discord's article on the verification an app needs before it can grow past 100 servers, which the guide separates from privileged intent review.
  • discord.py — The library whose run() reconnect behaviour, max_messages, member_cache_flags and chunk_guilds_at_startup options, and blocking FAQ the guide describes.
  • discord.js Guide — The makeCache and sweepers options the sizing section recommends for bounding memory in a discord.js bot.
  • Telegram Bot API — getUpdates with its timeout and offset parameters, setWebhook with its ports, certificate upload and secret_token header, and the 24 hour retention of undelivered updates.
  • Telegram Bots FAQ — The per-chat, per-group and broadcast sending limits quoted in the Telegram section.
  • BotFather — The /token command for replacing a compromised Telegram token, and BotFather's warning that anyone holding a token can control the bot.
  • GitHub secret scanning — Lists Discord bot tokens as a partner pattern with push protection, which is why a token pushed to a public repository is reported to Discord.
  • systemd — Restart=on-failure, the 100 ms default restart delay, and the start rate limiting that leaves a fast-failing unit stopped.
  • Docker restart policies — The unless-stopped and always policies, and the rule that a policy only applies once a container has stayed up for 10 seconds.
  • PM2 — pm2 startup and pm2 save, the process manager route to bringing a Node bot back after a reboot.
  • npm ci — The lock-file install the guide recommends for Node bots, and how it behaves when package.json and the lock file disagree.
  • pip: repeatable installs — Pinning with ==, generating a pinned file with pip freeze, and hash-checking mode.
  • SQLite — Why copying a live database file can produce a corrupt backup, and the VACUUM INTO and backup API alternatives the state section recommends.
  • Anthropic Python SDK — The example provider in the AI section: its 10 minute default timeout, two automatic retries, and reading ANTHROPIC_API_KEY from the environment.

Related guides

How Much RAM Does a Minecraft Server Need?

Size a Minecraft server heap by player count and modpack weight, learn to read MSPT and GC, and find out when more RAM genuinely will not help.

Read the guide

Paper vs Forge vs Fabric for a Minecraft Server

Paper runs plugins; Forge, NeoForge and Fabric run mods. Which to pick, which Java you need, what 26.1 changed, and how to move a world.

Read the guide

Minecraft Server Lagging? How to Diagnose and Fix TPS

Your Minecraft server lags: is it TPS, ping or client FPS? Diagnose the right one in 60 seconds, then fix it with settings changes that cost nothing.

Read the guide

How to Host a Rust Server: Wipes, Oxide, Map Seeds

A working guide to hosting Rust: force wipe mechanics and the exact files to delete, Oxide vs Carbon, worldsize versus RAM, and a first-wipe checklist.

Read the guide

Self-Hosting vs Renting a Game Server: Honest Costs

Real numbers on self-hosting versus renting a game server: upload per player, CGNAT, DDoS exposure, watts, uptime, and when self-hosting wins.

Read the guide

How to Commission a Custom Minecraft Plugin

When a custom Minecraft plugin is worth paying for, how to write a brief that gets a fixed price, a worked Varo example, and what to own at handover.

Read the guide

How to Set Up a CS2 Server With Plugins

Set up a Counter-Strike 2 dedicated server: disk and RAM it really needs, the Steam login token, Metamod:Source, CounterStrikeSharp and Workshop maps.

Read the guide

CS:GO Server Hosting in 2026: Move to CS2?

Looking for CS:GO server hosting? What changed when CS2 replaced CS:GO, what still works, and how to move a community, retake or practice server across.

Read the guide

Valheim Dedicated Server: Mods, RAM and Cost

Run a Valheim dedicated server with BepInEx mods: how much RAM it needs, which mods go on the server, crossplay, world backups and what it costs to rent.

Read the guide

How Much Does an ARK Ascended Server Cost?

What an ARK: Survival Ascended server costs to rent and why: RAM per map, why player slots are not the price, clusters, mods and what to check before you pay.

Read the guide

How Game Server Hosting Works at Puranode

What happens from the moment you ask for a game server to the moment friends join: setup, the control panel, mods, billing and what the price includes.

Read the guide

How Custom Plugin Development Works: Brief to Build

How commissioning a custom plugin or mod works at Puranode: the brief, the fixed quote, building and testing, delivery, and what you own at the end.

Read the guide

How AI Agent and Bot Hosting Works at Puranode

How hosting a Discord bot, Telegram bot or AI agent works: deploying your code, keeping API keys out of it, automatic restarts, storage and plans.

Read the guide

How Puranode Web Hosting Works: Containers, SSL, Domains

How website hosting in an isolated container works: what you get on day one, the free subdomain and SSL, uploading a site, and pointing your own domain.

Read the guide

How the Trading Bot Builder Works: Backtest to Export

How the Puranode trading bot builder works: setting rules, backtesting on real hourly candles in your browser, and exporting Python and TradingView code.

Read the guide

Enshrouded 1.0 Dedicated Server Setup Guide

Set up an Enshrouded 1.0 dedicated server: the RAM and port it needs, enshrouded_server.json explained, moving your world and launch day updates.

Read the guide

Palworld Dedicated Server Setup: RAM and Ports

Set up a Palworld dedicated server: Pocketpair's RAM and CPU figures, UDP port 8211, PalWorldSettings.ini, the REST API, moving saves and restarts.

Read the guide

Terraria Server Setup: TShock or tModLoader

Set up a Terraria dedicated server: vanilla, TShock or tModLoader, RAM by world size, port 7777, serverconfig.txt, moving a world and backups.

Read the guide

Satisfactory Dedicated Server Setup and Ports

Set up a Satisfactory dedicated server: ports 7777 and 8888 explained, RAM and CPU by factory size, claiming it, uploading a save, autosaves and updates.

Read the guide

Project Zomboid Dedicated Server Setup Guide

Set up a Project Zomboid dedicated server on Build 42: the two UDP ports, Java memory, servertest.ini, admin, Workshop mods, saves and wipes.

Read the guide

7 Days to Die Dedicated Server Setup Guide

Set up a 7 Days to Die dedicated server on V3: ports 26900 to 26903, serverconfig.xml and SandboxCode, world choice, admins, telnet, EAC and updates.

Read the guide

Move the bot off your laptop

Hobby runs one bot on 0.5 vCPU and 512 MB, with auto-restart on crash, for €4.99 a month. Standard runs up to three bots on 1 GB for €9.99. VAT included, hosted in France.