How to Host Rust Projects in the Cloud for Free
Grace Collins
Solutions Engineer · Leapcell
Axum is a modern, ergonomic, and highly performant web framework built with Rust, designed for building robust and scalable web applications. It leverages Rust’s strong type system and async support to ensure safety, reliability, and high performance.
In this post, I'll take Axum as an Rust example to show you how easy it is to deploy on Leapcell .
Why Leapcell
- Leapcell is the next-gen serverless platform for web hosting, allowing you to deploy entire Rust projects in the cloud.
- Leapcell only charges for actual usage, so you don't have to pay a penny when the machine is idle.
- Leapcell offers a generous free quota that resets every month. For daily usage, it's unlikely you'll exceed the quota.
1. Fork the Axum example on GitHub.
Repo: Axum example
Here’s the main.rs
file from that repository, borrowed from the official Axum documentation:
use axum::{response::Html, routing::get, Router}; #[tokio::main] async fn main() { // build our application with a route let app = Router::new().route("/", get(handler)); // run it let listener = tokio::net::TcpListener::bind("127.0.0.1:8080") .await .unwrap(); println!("listening on {}", listener.local_addr().unwrap()); axum::serve(listener, app).await.unwrap(); } async fn handler() -> Html<&'static str> { Html("<h1>Hello, World!</h1>") }
2. Create a Service in the Leapcell Dashboard and connect your new repository.
Go to the Leapcell Dashboard and click the New Service button.
On the "New Service" page, select the repository you just forked.
To access your repositories, you’ll need to connect Leapcell to your GitHub account.
Follow these instructions to connect to GitHub.
Once connected, your repositories will appear in the list.
3. Provide the following values during creation:
Since Rust is a compiled language, we will use cargo build --release
to build the Rust application.
In this example, our project name is app
, so it will compile to ./target/release/app
.
The start command should be ./target/release/app
instead of cargo run --release
. This is because cargo run
writes .cache
files, and the Leapcell environment does not support writing files in that path.
If you are using your own app, make sure the command matches your project. Replace app
with your project name and specify the correct start command (e.g., ./target/release/myapp
).
Field | Value |
---|---|
Runtime | Rust (Any version) |
Build Command | cargo build --release |
Start Command | ./target/release/app |
Port | 8080 |
Enter these values in the corresponding fields.
4. Access Your App:
Once deployed, you should see a URL like foo-bar.leapcell.dev on the Deployment page. Visit the domain shown on the service page.
Continuous Deployments
Every push to the linked branch automatically triggers a build and deploy. Failed builds are safely canceled, leaving the current version running until the next successful deploy.
Let's start deploying in Leapcell!