Sitemap

Actix-web | Auto Reload

Dec 11, 2025

--

Actix-web didn’t have feature auto-reload, So we will use cargo-watch to achieve this feature.

(Youtube video)

In terminal run :

cargo install cargo-watch

to install cargo-watch

Get Mike Code’s stories in your inbox

Join Medium for free to get updates from this writer.

Then let’s create a simple actix-web server in main.rs :

use actix_web::{   get, App, HttpResponse, HttpServer, Responder};

#[actix_web::main]
async fn main() {
HttpServer::new(|| {
App::new()

.service(hello)
})
.bind("0.0.0.0:3000")
.unwrap()
.run()
.await
.unwrap()
}

#[get("/")]
async fn hello() -> impl Responder {
HttpResponse::Ok().body("hello world")
}

We just created a simple http server with one route / and handler hello .

Then in terminal let’s run :

cargo watch -x run

to start our server.

So every time we modify our code , it will automatically reload the server , we don’t need to restart server by our own.

--

--