Guide

    Host a Discord bot for free on Oracle Cloud

    Free-tier PaaS providers sleep your bot after 15 minutes of inactivity. Oracle Cloud's Always Free ARM instances run 24/7 with 2 cores and 12 GB of RAM — the ideal home for a persistent Discord bot at $0/month. Here's the full setup for Node.js (discord.js) and Python (discord.py).

    Why Oracle Cloud Free Tier is the best free Discord bot host

    • Always-on — no cold starts, no sleep, no ping-me-awake hacks.
    • 2 ARM Ampere cores + 12 GB RAM — free forever. Room for dozens of bots.
    • 200 GB storage — plenty for logs, SQLite, and cached assets.
    • Full root access — install any runtime, any package, any version.
    • Fixed public IP — useful if your bot exposes a webhook or dashboard.

    Step 1 — Provision the ARM instance

    Sign up for Oracle Cloud (signup guide) and launch an Ampere A1.Flex shape with 1–2 OCPUs and 6–12 GB RAM. Ubuntu 22.04 is the easiest image. Hitting "Out of host capacity"? Use our retry script — it usually gets an instance within a few hours.

    Step 2 — Create a dedicated user and directory

    sudo adduser --system --group --home /opt/bot bot
    sudo mkdir -p /opt/bot/app && sudo chown -R bot:bot /opt/bot

    Step 3a — Node.js (discord.js) setup

    # Install Node 20 (ARM64)
    curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
    sudo apt install -y nodejs
    
    sudo -u bot bash -c 'cd /opt/bot/app && npm init -y && npm i discord.js dotenv'

    Minimal /opt/bot/app/index.js:

    import 'dotenv/config';
    import { Client, GatewayIntentBits, Events } from 'discord.js';
    
    const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
    
    client.once(Events.ClientReady, (c) => console.log(`Ready as ${c.user.tag}`));
    client.on(Events.MessageCreate, (m) => {
      if (m.content === '!ping') m.reply('pong 🏓');
    });
    
    client.login(process.env.DISCORD_TOKEN);

    Add "type": "module" to package.json, then drop your bot token in /opt/bot/app/.env as DISCORD_TOKEN=....

    Step 3b — Python (discord.py) setup

    sudo apt install -y python3-venv
    sudo -u bot bash -c 'python3 -m venv /opt/bot/venv && /opt/bot/venv/bin/pip install -U discord.py python-dotenv'

    Minimal /opt/bot/app/bot.py:

    import os, discord
    from dotenv import load_dotenv
    load_dotenv('/opt/bot/app/.env')
    
    intents = discord.Intents.default(); intents.message_content = True
    client = discord.Client(intents=intents)
    
    @client.event
    async def on_ready():
        print(f'Ready as {client.user}')
    
    @client.event
    async def on_message(m):
        if m.author.bot: return
        if m.content == '!ping': await m.reply('pong 🏓')
    
    client.run(os.environ['DISCORD_TOKEN'])

    Step 4 — Run under systemd (auto-restart forever)

    # /etc/systemd/system/discord-bot.service
    [Unit]
    Description=Discord Bot
    After=network-online.target
    
    [Service]
    User=bot
    WorkingDirectory=/opt/bot/app
    # Node:
    ExecStart=/usr/bin/node index.js
    # Python (comment out Node line, uncomment this):
    # ExecStart=/opt/bot/venv/bin/python bot.py
    Restart=always
    RestartSec=5
    
    [Install]
    WantedBy=multi-user.target
    sudo systemctl daemon-reload
    sudo systemctl enable --now discord-bot
    sudo journalctl -u discord-bot -f   # live logs

    Step 5 — Keep the token safe

    Lock down permissions so only the bot user can read the token:

    sudo chmod 600 /opt/bot/app/.env
    sudo chown bot:bot /opt/bot/app/.env

    If you leak a token, rotate it immediately in the Discord Developer Portal.

    Optional — Dockerized bot

    If you'd rather ship a container, our free Dockerfile generator produces an ARM64-ready image for discord.js or discord.py in one click.

    Prefer to skip the Linux chores?

    Cheaploy automates Oracle provisioning + Docker + systemd — point it at a GitHub repo and your bot is live in under 10 minutes on your own free Oracle tenancy.

    Frequently asked

    Will my Discord bot sleep on Oracle Cloud like it does on Render or Replit?+

    No. Oracle's Always Free ARM VMs run continuously. There's no idle timeout — your bot's websocket connection to the Discord gateway stays open forever.

    How many bots can I run on one free Oracle instance?+

    Comfortably 5–15 small-to-medium bots on a single 2-core / 12 GB ARM VM. Each discord.js or discord.py process typically uses 60–200 MB of RAM idle.

    Will Oracle reclaim my instance for being 'idle'?+

    Oracle only reclaims Always Free instances after roughly 7 days of near-zero CPU and network. A running Discord bot keeps a heartbeat with Discord's gateway, which is enough activity to stay online indefinitely.

    Do I need Docker?+

    No. A bare Node.js or Python process under systemd works great. Docker is optional — useful if you want reproducible deploys or want to run several bots in isolated containers.

    Deploy your project for $0

    No credit card. No Oracle sales call. Ship to your own cloud in under 10 minutes.

    Start free