September 21, 2026 · 8 min read · by the Discordfinder team

How to host a Discord bot 24/7 in 2026: costs, free tiers and what actually stays online

Verified 2026 prices for Railway, Fly.io, Render, Oracle, Hetzner, DigitalOcean and a Raspberry Pi, why sleeping free tiers break gateway bots, and the supervisor setup that keeps a bot online.

If you are working out how to host a Discord bot 24/7 without babysitting it, the honest answer in 2026 is: pay a few dollars a month for a small always-on machine, run the bot under a supervisor that restarts it, and stop hunting for a free tier that sleeps. The cheapest dependable options are a Fly.io machine at about $2, a DigitalOcean droplet at $4, Railway Hobby at $5, a Hetzner server at about €5.50, or a Raspberry Pi you already own. Oracle Cloud's Always Free tier costs nothing but has an idle-reclaim rule that a quiet bot trips. Below is what a bot actually needs, what each host costs today, and the supervision setup that keeps it online.

What a Discord bot actually needs from a host

A gateway bot is a long-lived process that opens one outbound connection and keeps it open. Discord's docs put it plainly: "The Gateway API lets apps open secure WebSocket connections with Discord to receive events about actions that take place in a server/guild." Your process dials out, sends heartbeats, receives events. Nothing dials in.

That has three consequences for hosting.

  • You do not need an inbound port, a domain or a TLS certificate. The exception is a bot built on HTTP interactions instead of the gateway: then Discord needs "a public endpoint for your app where Discord can send your app HTTP-based interactions", you must validate the X-Signature-Ed25519 and X-Signature-Timestamp headers on every request, and you "must send an initial response within 3 seconds of receiving the event".
  • Memory matters more than CPU. A small discord.py or discord.js bot in a few dozen servers is idle most of the time; what it needs is enough RAM to stay resident. Railway's Free plan caps a service at 0.5 GB RAM and that is comfortable for a bot with no large caches.
  • Sleep is fatal. Platforms pause idle web services when no HTTP traffic arrives. A gateway bot never receives HTTP traffic, so it looks idle from the first minute.

Why sleeping free tiers break gateway bots

Render is the clearest example. Its docs state that "Render spins down a Free web service that goes 15 minutes without receiving any inbound traffic", and that "Other service types don't support Free instances", so you cannot dodge the rule by deploying as a background worker. Render also says it "might restart a Free web service at any time".

People work around this with a keep-alive pinger hitting a dummy web route, which turns a bot into a web service plus a cron job plus hope. Pay $7 for a Starter instance (512 MB, 0.5 CPU) or host elsewhere.

Heroku and Replit: what changed

Heroku announced in August 2022: "Starting November 28, 2022, we plan to stop offering free product plans and plan to start shutting down free dynos and data services." There has been no free dyno since.

Replit retired the feature most bot tutorials leaned on. Its September 2023 post said "Always On will be fully removed from the product on January 1st, 2024. After January 1st, Deployments will be the only way to host applications on Replit." The deployment type for a bot is a Reserved VM, which runs "on a dedicated virtual machine that never sleeps"; the smallest tier is 0.5 vCPU with 2 GB RAM at $15.00 per month, deducted from plan credits. The free Starter plan "Includes 1 free published app. The deployment expires after 30 days but can be re-published." That is a demo, not hosting. Core dropped to $20 per month in February 2026, and a Reserved VM still consumes $15 of its credits every month.

Cost per month, option by option

Prices were checked on the official pricing pages on 21 September 2026 and exclude VAT.

Option What you get Cost per month Catch
Railway Free $1 usage credit, max 1 vCPU and 0.5 GB RAM $0 RAM is $10 per GB-month, so $1 covers about six days of a 0.5 GB container
Railway Hobby $5 of included usage, RAM $10 per GB, CPU $20 per vCPU $5 A 0.5 GB bot uses the included amount on RAM alone; light CPU adds a little
Fly.io shared-cpu-1x, 256 MB $2.02 (Amsterdam) Trial is "2 hours of machine runtime or 7 days of access, whichever comes first", then a card
Render Starter 512 MB, 0.5 CPU $7 Free web services sleep after 15 minutes; workers have no free tier
Oracle Always Free Arm A1: 2 OCPUs and 12 GB, or two E2.1.Micro $0 Idle instances can be reclaimed, see below
Hetzner CX23 or CAX11 2 vCPU, 4 GB, 40 GB NVMe, 20 TB traffic €5.49 or €5.99 Excludes IPv4 and VAT; prices rose on 15 June 2026; stock comes and goes
DigitalOcean Basic 1 vCPU, 512 MiB, 10 GiB SSD $4.00 Tight but workable for one bot
Raspberry Pi 5 at home 2 GB $65 or 4 GB $110, one-off Electricity only Three price rises since December 2025; your home power and broadband become the uptime

Oracle is the only real free option, and the docs are explicit: "Idle Always Free compute instances may be reclaimed by Oracle." An instance counts as idle when, over a 7-day period, CPU utilisation at the 95th percentile is under 20%, network utilisation is under 20% and, on A1 shapes, memory utilisation is under 20%. A lone bot meets all three. Run something else useful on the same box, or keep a backup host ready.

Hetzner raised prices on 15 June 2026: the CX23 went from €3.99 to €5.49 and the Arm CAX11 from €4.49 to €5.99, both before the IPv4 add-on. When we checked the cost-optimised page on 21 September 2026, both showed "This product is currently unavailable. Please check back later." Check stock before you plan around it.

Raspberry Pi prices have moved three times since December 2025 because of what Raspberry Pi calls "a seven-fold increase over the last year in the price of the LPDDR4 DRAM". A 2 GB Pi 5 went from $55 to $65 and a 4 GB from $70 to $110 over those rounds; the 16 GB model is now $305. A Pi still works for one small bot, but it is no longer the obvious bargain, and it inherits your home uptime.

Keep the process alive with systemd or Docker

On any VPS or a Pi, do not run the bot in a screen session. Give it a unit file.

# /etc/systemd/system/mybot.service
[Unit]
Description=Discord bot
After=network-online.target
Wants=network-online.target

[Service]
User=bot
WorkingDirectory=/opt/mybot
EnvironmentFile=/etc/mybot.env
ExecStart=/opt/mybot/.venv/bin/python -m bot
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

Enable it with sudo systemctl enable --now mybot and tail it with journalctl -u mybot -f. Restart=on-failure restarts the service "when the process exits with a non-zero exit code, is terminated by a signal", when an operation times out, or when the watchdog fires. If your library exits cleanly after a lost session, use Restart=always. RestartSec "Defaults to 100ms", which is a crash loop waiting to happen; five seconds is kinder to Discord's identify limits.

In Docker the equivalent is one flag.

docker run -d --name mybot \
  --restart unless-stopped \
  --env-file /etc/mybot.env \
  --memory 512m \
  ghcr.io/you/mybot:latest

unless-stopped is "Similar to always, except that when the container is stopped (manually or otherwise), it isn't restarted even after Docker daemon restarts." One trap: "A restart policy only takes effect after a container starts successfully. In this case, starting successfully means that the container is up for at least 10 seconds". A bot that dies on a bad token in the first second is not retried, so check docker logs mybot after the first deploy.

Secrets, logging and health checks

  • Token: an environment variable, never a file in the repo. The EnvironmentFile and --env-file lines above keep it out of ps output and out of git. If it ever lands in a commit, reset it in the Developer Portal under Bot → Reset Token and redeploy.
  • Logging: write to stdout and let the supervisor capture it. Log every gateway reconnect and resume; a rising count is your earliest sign of a flaky host. Discord allows "120 gateway events per connection every 60 seconds", so log when you hit that limiter rather than silently queueing.
  • Health checks: the process has no inbound port, so a platform HTTP check has nothing to hit. Either expose a one-line /health route on a private port that reports the age of the last heartbeat ack, or watch from outside. Discordfinder pings monitored bots every 5 minutes and shows 30-day uptime on the listing, so a host that drops you every night is visible to anyone comparing bots.

Sharding and the 2,500-guild line

Discord's rule is fixed: "Each shard can only support a maximum of 2500 guilds, and apps that are in 2500+ guilds must enable sharding." Below that, one process and one connection are fine. Above it your library opens more connections, and memory grows with cached guilds and members, so a 512 MB box stops being enough.

Identify requests are also rate limited through max_concurrency, the "Number of identify requests allowed per 5 seconds", which is why a restart loop on a large bot can lock you out for a while. Move to a 2 to 4 GB machine before you cross the line, not after.

Which one to pick

  • Learning, or a bot for one server: Fly.io at $2.02 or DigitalOcean at $4.
  • You would rather not touch a shell: Railway Hobby at $5, with logs in the dashboard. Skip the Free plan's $1 credit for anything you want online next week.
  • Free at any cost: Oracle Always Free on Arm, with a second workload so it never looks idle, and a backup host.
  • Most RAM per euro: Hetzner CAX11 with 4 GB, if it is in stock.
  • Already own a Pi: fine for one small bot; put it on a UPS and accept that your broadband, not the Pi, is the weak link.

If you get stuck on a reconnect loop, the communities in best Discord servers for programmers and under /tags/programming are where people debug this daily.

Try it: Once your bot stays up, list it at /add-bot. Monitored bots are pinged every 5 minutes and the listing shows 30-day uptime, so a solid hosting choice is visible to server owners browsing /bots.