r/rust•
skeeterah

Actix-web backend randomly not logging requests & Cloudflare 524 timeouts, even on trivial handlers

First off this is probably the wrong subreddit for this but idk...

I’m making an Actix-Web backend. I have multiple routes, all async and non-blocking — nothing heavy or blocking anywhere.

But sometimes my frontend makes a request, and the backend just... ignores it. My .wrap_fn that logs Received request: <path> never prints for those requests. Then after a while Cloudflare throws a 524 timeout.

This happens totally randomly, not during high traffic or anything.

I’ve tried increasing and decreasing workers, turning on trace logging and testing direct to backend, no Cloudflare

I also have .on_connect() logging for new connections, but sometimes those requests that 524 don’t even show a “Got connection” log.

I made a health endpoint that literally just returns 200 and sometimes even that has issues and there is nothing on it.

#[get("/health")]
pub async fn health() -> impl actix_web::Responder {
    HttpResponse::Ok().
finish
()
}

Feels like something’s stuck or blocked before my middleware even gets the request, but I’m stumped and stupid.

I'm not 100% new but pretty new to Actix Web and Rust.

Here is my basic HttpService

    HttpServer::new(move || {
        App::new()
            .app_data(actix_web::web::Data::new(state.clone()))
            .wrap(actix_web::middleware::Logger::default())
            .wrap(default_cors())
            .configure(|
cfg
| get_config(
cfg
))
            .wrap_fn(|req, srv| {
                println!(">>> Received request: {}", req.path());
                srv.call(req)
            })
    })
    .on_connect(|_, 
__
| {
        println!("Got connection");
    })
    .bind(("0.0.0.0", port))?
    .run()
    .await

Posted Jun 15, 2025, 3:10 PM UTC

05
Loading comments…