Has anyone tried to use actix-web crate

When I deploy the program on the server, a 502 error occurs when accessing, but the port monitored by the service is running. The following is my main program configuration, I can access it normally when debugging and running on local machine.

use actix_web::{get, web, App, HttpServer, Responder};
use api::user_api;

#[tokio::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        App::new()
            .route("/hello", web::get().to(|| async { "api server run successed" }))
            .service(user_api::register)
    })
    .bind(("localhost", 8082))?
    .run()
    .await
}

By the way, I don't use SSL

You're binding to localhost, are you accessing on localhost? In not familiar with actix-web specifically, but I expect you would have to bind to "0.0.0.0" to accept remote connections.

1 Like

I seem to remember something. I'll try

ty :smile:

1 Like

No problem!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.