Deploy Rust apps

Rust support is in private beta

If you are interested in accessing the beta test, please contact the support.

Clever Cloud allows you to deploy rust web applications. This page will explain you how to set up your application to run it on our service.

You do not need to change a lot in your application, the requirements will help you to configure your apps with some mandatory files to add, and properties to setup.


Rust is a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety. You can build rust web services with frameworks like Iron

Create an application

Refer to the page Deploy an application on Clever Cloud.

Necessary information

Be sure that:

  • you have pushed in master branch
  • you listen on port 8080
  • you have committed Cargo.lock
  • you have at least one binary target in Cargo.toml


The result of cargo run --release --locked must be a process listening on

For instance, a minimal iron application can look like this:

extern crate iron;

use iron::prelude::*;
use iron::status;

fn main() {
    fn hello_world(_: &mut Request) -> IronResult<Response> {
        Ok(Response::with((status::Ok, "Hello World!")))

    let _server = Iron::new(hello_world).http("").unwrap();
    println!("On 8080");

Multiple binary targets

If your Cargo.toml defines multiple targets, you must specify the one you want to run, with the CARGO_BIN environment variable. If CARGO_BIN is specified, then cargo run --release --bin "${CARGO_BIN}" is used to start the application.


Make sure to list all your dependencies in Cargo.toml. For the example above, you need:

name = "my-app"
version = "0.1.0"
authors = []

iron = "0.4.0"

Compiled dependencies are cached by default to speed up deployments. You can disable dependencies caching completely by removing the CACHE_DEPENDENCIES environment variable. If you want to rebuild your application from scratch, you can select "rebuild and restart" from the console or launch clever restart --without-cache from CLI.

Rust channels

By default, your application is built with the latest stable version. If you require beta, nightly or a specific rust version, you can set RUSTUP_CHANNEL to beta, nightly or a specific version (eg. 1.13.0). The build uses rustup to select the rust version you need.

Environment injection

Clever Cloud can inject environment variables that are defined in the dashboard and by add-ons linked to your application.

You can access environment variables with std::env::var(<KEY_NAME>).

If environment variables are needed for your application to work properly, the best solution is to load them in your main function and use .expect to fail early with a descriptive error.

use std::env;

fn main() {
    let my_config_value = env::var("MY_KEY").expect("Missing env var `MY_KEY`");


For more information, you can read about environment variables on Clever Cloud.

Deploy on Clever Cloud

Application deployment on Clever Cloud is via Git. Follow these steps to deploy your application.