Actix web 4.0 failing on deploy

I am trying to deploy a simple actix web api. However everytime I try and deploy it fails without any error messages

May 31 10:43:50 AM   ==> Cloning from https://github.com/SorenHolstHansen/whats-open...
May 31 10:43:51 AM   ==> Checking out commit 7c6b2554cb4298904ac52a0ec6eb7124570eb1d3 in branch main
May 31 10:43:56 AM   ==> Downloading cache...
May 31 10:44:04 AM   info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
May 31 10:44:05 AM   info: latest update on 2022-05-19, rust version 1.61.0 (fe5b13d68 2022-05-18)
May 31 10:44:05 AM   info: downloading component 'cargo'
May 31 10:44:05 AM   info: downloading component 'clippy'
May 31 10:44:05 AM   info: downloading component 'rust-docs'
May 31 10:44:05 AM   info: downloading component 'rust-std'
May 31 10:44:06 AM   info: downloading component 'rustc'
May 31 10:44:07 AM   info: downloading component 'rustfmt'
May 31 10:44:07 AM   info: installing component 'cargo'
May 31 10:44:08 AM   info: installing component 'clippy'
May 31 10:44:09 AM   info: installing component 'rust-docs'
May 31 10:44:13 AM   info: installing component 'rust-std'
May 31 10:44:17 AM   info: installing component 'rustc'
May 31 10:44:25 AM   info: installing component 'rustfmt'
May 31 10:44:25 AM  
May 31 10:44:25 AM   info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'
May 31 10:44:25 AM     stable-x86_64-unknown-linux-gnu installed - rustc 1.61.0 (fe5b13d68 2022-05-18)
May 31 10:44:25 AM  
May 31 10:44:25 AM   ==> Running build command 'cargo build -p api --release'...
May 31 10:44:26 AM       Updating crates.io index
May 31 10:45:57 AM    Downloading crates ...
May 31 10:45:58 AM     Downloaded ryu v1.0.9
May 31 10:45:58 AM     Downloaded tokio-util v0.7.1
May 31 10:45:58 AM     Downloaded actix-http v3.0.4
May 31 10:45:58 AM     Downloaded autocfg v1.1.0
May 31 10:45:58 AM     Downloaded block-buffer v0.10.2
May 31 10:45:58 AM     Downloaded alloc-stdlib v0.2.1
May 31 10:45:58 AM     Downloaded cpufeatures v0.2.2
May 31 10:45:58 AM     Downloaded alloc-no-stdlib v2.0.3
May 31 10:45:58 AM     Downloaded cc v1.0.73
May 31 10:45:58 AM     Downloaded convert_case v0.4.0
May 31 10:45:58 AM     Downloaded digest v0.10.3
May 31 10:45:58 AM     Downloaded derive_more v0.99.17
May 31 10:45:58 AM     Downloaded getrandom v0.2.6
May 31 10:45:58 AM     Downloaded bytes v1.1.0
May 31 10:45:58 AM     Downloaded actix-web-codegen v4.0.0
May 31 10:45:58 AM     Downloaded actix-rt v2.7.0
May 31 10:45:58 AM     Downloaded adler v1.0.2
May 31 10:45:58 AM     Downloaded log v0.4.17
May 31 10:45:58 AM     Downloaded firestorm v0.5.0
May 31 10:45:58 AM     Downloaded cookie v0.16.0
May 31 10:45:58 AM     Downloaded actix-service v2.0.2
May 31 10:45:58 AM     Downloaded local-waker v0.1.3
May 31 10:45:58 AM     Downloaded form_urlencoded v1.0.1
May 31 10:45:58 AM     Downloaded futures-sink v0.3.21
May 31 10:45:58 AM     Downloaded futures-core v0.3.21
May 31 10:45:58 AM     Downloaded fnv v1.0.7
May 31 10:45:58 AM     Downloaded generic-array v0.14.5
May 31 10:45:58 AM     Downloaded ahash v0.7.6
May 31 10:45:58 AM     Downloaded cfg-if v1.0.0
May 31 10:45:58 AM     Downloaded matches v0.1.9
May 31 10:45:58 AM     Downloaded aho-corasick v0.7.18
May 31 10:45:58 AM     Downloaded futures-util v0.3.21
May 31 10:45:58 AM     Downloaded tracing v0.1.34
May 31 10:45:58 AM     Downloaded unicode-xid v0.2.3
May 31 10:45:58 AM     Downloaded local-channel v0.1.3
May 31 10:45:58 AM     Downloaded proc-macro2 v1.0.38
May 31 10:45:58 AM     Downloaded language-tags v0.3.2
May 31 10:45:58 AM     Downloaded actix-server v2.1.1
May 31 10:45:58 AM     Downloaded lazy_static v1.4.0
May 31 10:45:58 AM     Downloaded jobserver v0.1.24
May 31 10:45:58 AM     Downloaded num_threads v0.1.6
May 31 10:45:58 AM     Downloaded num_cpus v1.13.1
May 31 10:45:58 AM     Downloaded memchr v2.5.0
May 31 10:45:58 AM     Downloaded http v0.2.7
May 31 10:45:58 AM     Downloaded mio v0.8.3
May 31 10:45:58 AM     Downloaded indexmap v1.8.1
May 31 10:45:58 AM     Downloaded httpdate v1.0.2
May 31 10:45:58 AM     Downloaded actix-utils v3.0.0
May 31 10:45:58 AM     Downloaded hashbrown v0.11.2
May 31 10:45:58 AM     Downloaded slab v0.4.6
May 31 10:45:58 AM     Downloaded tracing-core v0.1.26
May 31 10:45:58 AM     Downloaded tracing-attributes v0.1.21
May 31 10:45:58 AM     Downloaded tokio v1.18.2
May 31 10:45:58 AM     Downloaded quote v1.0.18
May 31 10:45:58 AM     Downloaded pin-utils v0.1.0
May 31 10:45:58 AM     Downloaded rustc_version v0.4.0
May 31 10:45:58 AM     Downloaded signal-hook-registry v1.4.0
May 31 10:45:58 AM     Downloaded unicode-normalization v0.1.19
May 31 10:45:58 AM     Downloaded tinyvec_macros v0.1.0
May 31 10:45:58 AM     Downloaded zstd v0.10.2+zstd.1.5.2
May 31 10:45:58 AM     Downloaded smallvec v1.8.0
May 31 10:45:58 AM     Downloaded miniz_oxide v0.5.1
May 31 10:45:58 AM     Downloaded url v2.2.2
May 31 10:45:58 AM     Downloaded serde_json v1.0.81
May 31 10:45:58 AM     Downloaded itoa v1.0.1
May 31 10:45:58 AM     Downloaded bytestring v1.0.0
May 31 10:45:58 AM     Downloaded rand v0.8.5
May 31 10:45:58 AM     Downloaded time-macros v0.2.4
May 31 10:45:58 AM     Downloaded socket2 v0.4.4
May 31 10:45:58 AM     Downloaded serde v1.0.137
May 31 10:45:58 AM     Downloaded zstd-safe v4.1.6+zstd.1.5.2
May 31 10:45:58 AM     Downloaded version_check v0.9.4
May 31 10:45:58 AM     Downloaded typenum v1.15.0
May 31 10:45:58 AM     Downloaded tinyvec v1.6.0
May 31 10:45:58 AM     Downloaded time v0.3.9
May 31 10:45:58 AM     Downloaded paste v1.0.7
May 31 10:45:58 AM     Downloaded regex-syntax v0.6.25
May 31 10:45:58 AM     Downloaded semver v1.0.9
May 31 10:45:58 AM     Downloaded lock_api v0.4.7
May 31 10:45:58 AM     Downloaded futures-task v0.3.21
May 31 10:45:58 AM     Downloaded crypto-common v0.1.3
May 31 10:45:58 AM     Downloaded idna v0.2.3
May 31 10:45:58 AM     Downloaded sha-1 v0.10.0
May 31 10:45:58 AM     Downloaded rand_chacha v0.3.1
May 31 10:45:58 AM     Downloaded once_cell v1.10.0
May 31 10:45:58 AM     Downloaded percent-encoding v2.1.0
May 31 10:45:58 AM     Downloaded mime v0.3.16
May 31 10:45:58 AM     Downloaded unicode-bidi v0.3.8
May 31 10:45:58 AM     Downloaded serde_urlencoded v0.7.1
May 31 10:45:58 AM     Downloaded scopeguard v1.1.0
May 31 10:45:58 AM     Downloaded regex v1.5.5
May 31 10:45:58 AM     Downloaded ppv-lite86 v0.2.16
May 31 10:45:58 AM     Downloaded pin-project-lite v0.2.9
May 31 10:45:58 AM     Downloaded parking_lot v0.12.0
May 31 10:45:58 AM     Downloaded rand_core v0.6.3
May 31 10:45:58 AM     Downloaded syn v1.0.94
May 31 10:45:58 AM     Downloaded zstd-sys v1.6.3+zstd.1.5.2
May 31 10:45:58 AM     Downloaded libc v0.2.125
May 31 10:45:59 AM     Downloaded encoding_rs v0.8.31
May 31 10:45:59 AM     Downloaded brotli v3.3.4
May 31 10:45:59 AM     Downloaded actix-web v4.0.1
May 31 10:45:59 AM     Downloaded parking_lot_core v0.9.3
May 31 10:45:59 AM     Downloaded flate2 v1.0.23
May 31 10:45:59 AM     Downloaded actix-router v0.5.0
May 31 10:45:59 AM     Downloaded httparse v1.7.1
May 31 10:45:59 AM     Downloaded h2 v0.3.13
May 31 10:45:59 AM     Downloaded crc32fast v1.3.2
May 31 10:45:59 AM     Downloaded bitflags v1.3.2
May 31 10:45:59 AM     Downloaded brotli-decompressor v2.3.2
May 31 10:45:59 AM     Downloaded base64 v0.13.0
May 31 10:45:59 AM     Downloaded actix-macros v0.2.3
May 31 10:45:59 AM     Downloaded actix-codec v0.5.0
May 31 10:45:59 AM      Compiling libc v0.2.125
May 31 10:45:59 AM      Compiling cfg-if v1.0.0
May 31 10:45:59 AM      Compiling memchr v2.5.0
May 31 10:45:59 AM      Compiling log v0.4.17
May 31 10:45:59 AM      Compiling proc-macro2 v1.0.38
May 31 10:45:59 AM      Compiling version_check v0.9.4
May 31 10:45:59 AM      Compiling autocfg v1.1.0
May 31 10:45:59 AM      Compiling unicode-xid v0.2.3
May 31 10:46:00 AM      Compiling pin-project-lite v0.2.9
May 31 10:46:00 AM      Compiling syn v1.0.94
May 31 10:46:01 AM      Compiling futures-core v0.3.21
May 31 10:46:02 AM      Compiling bytes v1.1.0
May 31 10:46:02 AM      Compiling parking_lot_core v0.9.3
May 31 10:46:02 AM      Compiling scopeguard v1.1.0
May 31 10:46:02 AM      Compiling smallvec v1.8.0
May 31 10:46:03 AM      Compiling serde v1.0.137
May 31 10:46:03 AM      Compiling typenum v1.15.0
May 31 10:46:03 AM      Compiling once_cell v1.10.0
May 31 10:46:03 AM      Compiling itoa v1.0.1
May 31 10:46:03 AM      Compiling lazy_static v1.4.0
May 31 10:46:04 AM      Compiling futures-task v0.3.21
May 31 10:46:04 AM      Compiling futures-util v0.3.21
May 31 10:46:05 AM      Compiling percent-encoding v2.1.0
May 31 10:46:05 AM      Compiling pin-utils v0.1.0
May 31 10:46:06 AM      Compiling futures-sink v0.3.21
May 31 10:46:06 AM      Compiling tinyvec_macros v0.1.0
May 31 10:46:06 AM      Compiling fnv v1.0.7
May 31 10:46:07 AM      Compiling zstd-safe v4.1.6+zstd.1.5.2
May 31 10:46:07 AM      Compiling crc32fast v1.3.2
May 31 10:46:07 AM      Compiling matches v0.1.9
May 31 10:46:07 AM      Compiling local-waker v0.1.3
May 31 10:46:08 AM      Compiling alloc-no-stdlib v2.0.3
May 31 10:46:08 AM      Compiling adler v1.0.2
May 31 10:46:08 AM      Compiling encoding_rs v0.8.31
May 31 10:46:09 AM      Compiling regex-syntax v0.6.25
May 31 10:46:10 AM      Compiling ppv-lite86 v0.2.16
May 31 10:46:10 AM      Compiling httparse v1.7.1
May 31 10:46:10 AM      Compiling hashbrown v0.11.2
May 31 10:46:10 AM      Compiling paste v1.0.7
May 31 10:46:10 AM      Compiling unicode-bidi v0.3.8
May 31 10:46:11 AM      Compiling firestorm v0.5.0
May 31 10:46:11 AM      Compiling serde_json v1.0.81
May 31 10:46:12 AM      Compiling cpufeatures v0.2.2
May 31 10:46:13 AM      Compiling slab v0.4.6
May 31 10:46:13 AM      Compiling time-macros v0.2.4
May 31 10:46:13 AM      Compiling num_threads v0.1.6
May 31 10:46:14 AM      Compiling convert_case v0.4.0
May 31 10:46:14 AM      Compiling ryu v1.0.9
May 31 10:46:16 AM      Compiling bitflags v1.3.2
May 31 10:46:17 AM      Compiling language-tags v0.3.2
May 31 10:46:18 AM      Compiling base64 v0.13.0
May 31 10:46:18 AM      Compiling httpdate v1.0.2
May 31 10:46:19 AM      Compiling mime v0.3.16
May 31 10:46:23 AM      Compiling generic-array v0.14.5
May 31 10:46:23 AM      Compiling ahash v0.7.6
May 31 10:46:24 AM      Compiling cookie v0.16.0
May 31 10:46:26 AM      Compiling lock_api v0.4.7
May 31 10:46:26 AM      Compiling indexmap v1.8.1
May 31 10:46:26 AM      Compiling tracing-core v0.1.26
May 31 10:46:27 AM      Compiling bytestring v1.0.0
May 31 10:46:28 AM      Compiling tinyvec v1.6.0
May 31 10:46:28 AM      Compiling http v0.2.7
May 31 10:46:28 AM      Compiling form_urlencoded v1.0.1
May 31 10:46:28 AM      Compiling actix-utils v3.0.0
May 31 10:46:31 AM      Compiling alloc-stdlib v0.2.1
May 31 10:46:32 AM      Compiling miniz_oxide v0.5.1
May 31 10:46:48 AM      Compiling brotli-decompressor v2.3.2
May 31 10:46:50 AM      Compiling unicode-normalization v0.1.19
May 31 10:46:53 AM      Compiling aho-corasick v0.7.18
May 31 10:47:07 AM      Compiling mio v0.8.3
May 31 10:47:09 AM      Compiling socket2 v0.4.4
May 31 10:47:12 AM      Compiling signal-hook-registry v1.4.0
May 31 10:47:15 AM      Compiling getrandom v0.2.6
May 31 10:47:18 AM      Compiling num_cpus v1.13.1
May 31 10:47:19 AM      Compiling time v0.3.9
May 31 10:47:20 AM      Compiling jobserver v0.1.24
May 31 10:47:22 AM      Compiling actix-service v2.0.2
May 31 10:47:28 AM      Compiling quote v1.0.18
May 31 10:47:28 AM      Compiling flate2 v1.0.23
May 31 10:47:31 AM      Compiling brotli v3.3.4
May 31 10:47:34 AM      Compiling idna v0.2.3
May 31 10:47:35 AM      Compiling regex v1.5.5
May 31 10:47:45 AM      Compiling serde_urlencoded v0.7.1
May 31 10:47:46 AM      Compiling rand_core v0.6.3
May 31 10:47:49 AM      Compiling cc v1.0.73
May 31 10:47:55 AM      Compiling parking_lot v0.12.0
May 31 10:48:01 AM      Compiling crypto-common v0.1.3
May 31 10:48:01 AM      Compiling block-buffer v0.10.2
May 31 10:48:02 AM      Compiling url v2.2.2
May 31 10:48:03 AM      Compiling local-channel v0.1.3
May 31 10:48:04 AM      Compiling actix-router v0.5.0
May 31 10:48:10 AM      Compiling rand_chacha v0.3.1
May 31 10:48:16 AM      Compiling tokio v1.18.2
May 31 10:48:17 AM      Compiling zstd-sys v1.6.3+zstd.1.5.2
May 31 10:48:19 AM      Compiling digest v0.10.3
May 31 10:48:21 AM      Compiling rand v0.8.5
May 31 10:48:21 AM      Compiling sha-1 v0.10.0
May 31 10:48:46 AM      Compiling actix-rt v2.7.0
May 31 10:48:49 AM      Compiling tracing-attributes v0.1.21
May 31 10:48:55 AM      Compiling derive_more v0.99.17
May 31 10:49:10 AM      Compiling actix-web-codegen v4.0.0
May 31 10:49:14 AM      Compiling actix-macros v0.2.3
May 31 10:49:20 AM      Compiling tracing v0.1.34
May 31 10:49:22 AM      Compiling tokio-util v0.7.1
May 31 10:49:26 AM      Compiling actix-server v2.1.1
May 31 10:49:27 AM      Compiling actix-codec v0.5.0
May 31 10:49:28 AM      Compiling h2 v0.3.13
May 31 10:50:20 AM      Compiling zstd v0.10.2+zstd.1.5.2
May 31 10:50:21 AM      Compiling actix-http v3.0.4
May 31 10:50:25 AM      Compiling actix-web v4.0.1
May 31 10:51:06 AM      Compiling api v0.1.0 (/opt/render/project/src/api)
May 31 10:51:25 AM       Finished release [optimized] target(s) in 6m 59s
May 31 10:51:25 AM   ==> Generating container image from build. This may take a few minutes...
May 31 11:00:17 AM   ==> Uploading build...
May 31 11:03:46 AM   ==> Build successful 🎉
May 31 11:03:46 AM   ==> Deploying...
May 31 11:05:07 AM  ==> Starting service with 'cargo run -p api --release'
May 31 11:05:16 AM      Finished release [optimized] target(s) in 7.21s
May 31 11:05:16 AM       Running `target/release/api`

The code is just the actix beginner example

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

#[get("/hello/{name}")]
async fn greet(name: web::Path<String>) -> impl Responder {
    format!("Hello {name}!")
}

#[actix_web::main] // or #[tokio::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        App::new()
            .route("/hello", web::get().to(|| async { "Hello World!" }))
            .service(greet)
    })
    .bind(("127.0.0.1", 4000))?
    .run()
    .await
}

And my Cargo.toml is this

[package]
name = "api"
version = "0.1.0"
edition = "2021"

[dependencies]
actix-web = "4"

Also, the api is in a monorepo, and the structure is this

  • backend
    • api
    • something else

My build script is cargo build -p api --release and the run script is cargo run -p api --release

What is wrong?

Hi,

It looks like you’re binding to localhost at port 4000 .bind(("127.0.0.1", 4000)). You will need to bind to 0.0.0.0 instead of 127.0.0.1 . Can you give that a try and see if the deploy succeeds?

Hi, thanks for the suggestion. I found out that it was the port that was the issue. I already have another site listening on port 4000, but on another team, so I didn’t think it would matter, but apparently you can’t have two services listening on the same port

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.