Skip to content

Rust Discord Bot Hosting

Rust bots compile into one small, fast binary. Upload your source and Cargo.toml, and the server runs cargo build --release on Rust 1.77 during install, then starts your bot.

After you change your code, press Reinstall to compile the new version.

Rust version
1.77
Build
cargo build --release at install
Updates
Upload new code, then Reinstall
Libraries
serenity, poise, twilight and more

A bot that runs here as it is

A minimal serenity bot. In Cargo.toml add serenity and tokio (with the macros and rt-multi-thread features).

src/main.rs
use serenity::async_trait;
use serenity::model::gateway::Ready;
use serenity::prelude::*;

struct Handler;

#[async_trait]
impl EventHandler for Handler {
    async fn ready(&self, _: Context, ready: Ready) {
        println!("Ready as {}", ready.user.name);
    }
}

#[tokio::main]
async fn main() {
    let token = std::env::var("DISCORD_TOKEN").expect("DISCORD_TOKEN is not set");
    let mut client = Client::builder(&token, GatewayIntents::GUILDS)
        .event_handler(Handler)
        .await
        .expect("could not create client");
    if let Err(why) = client.start().await {
        println!("Client error: {why:?}");
    }
}

How to host a Rust Discord bot on Zeros Host

  1. 1

    Create the bot in the Discord Developer Portal

    Go to discord.com/developers/applications, create an application, open the Bot tab and press Reset Token to copy your token. Under OAuth2, pick the bot and applications.commands scopes, choose the permissions your bot needs, and open the generated link to add the bot to your server.

  2. 2

    Create a Rust bot server

    Start a free trial or pick a Discord Bot plan and choose Rust.

  3. 3

    Add your bot token

    Open the Startup page for your server and paste your token into Discord Token. The panel passes it to your bot as the DISCORD_TOKEN environment variable, so it never has to sit inside your code or your Git repository.

  4. 4

    Upload Cargo.toml, Cargo.lock and src

    Upload your project to the root of the server with the File Manager or SFTP. Keep Cargo.lock so the server builds the same versions you tested.

  5. 5

    Reinstall to compile

    Press Reinstall in Settings. The install runs a release build and copies the binary named in your Cargo.toml so the server can start it.

    cargo build --release
  6. 6

    Start it

    Press Start and look for your ready line in the console.

Common Rust bot errors and fixes

A dependency requires a newer rustc

The server compiles with Rust 1.77. Pin the crate to an older version in Cargo.toml, update Cargo.lock locally, upload both and Reinstall.

The build ran out of memory

Big crates can need a lot of memory to compile. Move up a plan for the build, or build a Linux binary yourself, name it bot and upload it.

No Cargo.toml found

Upload Cargo.toml to the server root, next to the src folder, and Reinstall.

Used disallowed intents

Your code asks for a privileged intent (Message Content, Server Members or Presence) that is switched off for your bot. Turn it on under Bot, Privileged Gateway Intents in the Developer Portal, or remove it from your code.

An invalid token was provided

The token in Discord Token is wrong or was reset. Reset it in the Developer Portal, paste the new one on the Startup page and restart. Discord also resets tokens it finds in public GitHub repositories, so keep yours out of your code.

Which plan fits

A running Rust bot uses very little memory, so Starter at 256 MB covers most bots. Compiling large dependency trees is the heavy part, and Standard gives the build more room.

Starter

£1/mo

256 MB RAM · 5 GB

Standard

£3/mo

512 MB RAM · 10 GB

Suggested for this bot

Pro

£5/mo

1 GB RAM · 15 GB

Enterprise

£6/mo

2 GB RAM · 25 GB

Try it free for 48 hours

Start a 48-hour Discord bot trial with no card needed. Pick your runtime and your server is ready in seconds. Plans start at £1 a month after that.

Frequently asked questions

Can I skip the build on the server?

Yes. Cross compile for Linux amd64 on your own machine, name the binary bot and upload it to the server root. The server starts ./bot.

Does twilight work?

Yes. Any crate works as long as it compiles on Rust 1.77 and your code reads the DISCORD_TOKEN environment variable.

More Discord bot hosting guides