{"record":{"id":"5d6417a1d9416b8b","repo":"ruvnet/RuView","slug":"cannot-bind-http-listener-on-http-addr-e","errorCode":null,"errorMessage":"cannot bind HTTP listener on {http_addr}: {e}","messagePattern":"cannot bind HTTP listener on (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v2/crates/wifi-densepose-cli/src/calibrate_api.rs","lineNumber":363,"sourceCode":"\n    let state = ApiState { cmd_tx, status, window, fs_hz: 15.0, enroll };\n    let mut app = build_router(state);\n\n    // Optional bearer auth — required before any non-loopback exposure.\n    if let Some(token) = args.token.clone() {\n        app = app.layer(axum::middleware::from_fn_with_state(token, require_bearer));\n        eprintln!(\"[calibrate-serve] bearer auth ENABLED\");\n    } else if args.http_bind != \"127.0.0.1\" && args.http_bind != \"localhost\" {\n        eprintln!(\n            \"[calibrate-serve] WARNING: bound to {} with NO --token — anyone on the network can drive calibration\",\n            args.http_bind\n        );\n    }\n\n    let http_addr = format!(\"{}:{}\", args.http_bind, args.http_port);\n    let listener = tokio::net::TcpListener::bind(&http_addr)\n        .await\n        .map_err(|e| anyhow::anyhow!(\"cannot bind HTTP listener on {http_addr}: {e}\"))?;\n    eprintln!(\"[calibrate-serve] HTTP API on http://{http_addr}  (GET / for the route list)\");\n\n    axum::serve(listener, app)\n        .await\n        .map_err(|e| anyhow::anyhow!(\"HTTP server error: {e}\"))?;\n    Ok(())\n}\n\n// ---------------------------------------------------------------------------\n// Ingest task — owns the UDP socket and the optional active recorder\n// ---------------------------------------------------------------------------\n\nstruct ActiveSession {\n    recorder: CalibrationRecorder,\n    room_id: String,\n    tier: String,\n    started: Instant,\n    deadline: Instant,","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/v2/crates/wifi-densepose-cli/src/calibrate_api.rs#L345-L381","documentation":"tokio TcpListener::bind failed for the HTTP API address {http_bind}:{http_port} in calibrate-serve. io::Error causes: AddrInUse (another HTTP service or a second calibrate-serve on that port), permission denied on privileged ports, or a --http-bind address the host does not own. This is a startup failure, distinct from runtime serve errors.","triggerScenarios":"Another web service already listening on the chosen port; --http-port below 1024 as non-root; --http-bind set to an address not present on the host.","commonSituations":"Collisions with dev servers on common ports like 8080; container port maps where the host port is taken; typo'd bind address; running two calibration API instances on one host.","solutions":["Stop the occupying process or choose a different --http-port (ss -tlnp to find it)","Use a port of 1024 or higher, or grant CAP_NET_BIND_SERVICE for low ports","Set --http-bind to an address that exists on the host (127.0.0.1 for local, the NIC IP for LAN)","When binding non-loopback, pass --token — the code warns that an unauthenticated LAN-bound API lets anyone drive calibration"],"exampleFix":"// before\n$ ruview calibrate-serve --http-bind 0.0.0.0 --http-port 80   # permission denied / AddrInUse\n\n// after\n$ ruview calibrate-serve --http-bind 0.0.0.0 --http-port 8080 --token <secret>","handlingStrategy":"validation","validationCode":"fn tcp_port_free(bind: &str, port: u16) -> bool {\n    std::net::TcpListener::bind((bind, port)).is_ok()\n}","typeGuard":null,"tryCatchPattern":"match tokio::net::TcpListener::bind(&http_addr).await {\n    Ok(listener) => listener,\n    Err(e) if e.kind() == std::io::ErrorKind::AddrInUse => {\n        return Err(anyhow::anyhow!(\"http://{http_addr} already in use — stop the other service or change --http-port\"));\n    }\n    Err(e) => return Err(anyhow::anyhow!(\"cannot bind HTTP listener on {http_addr}: {e}\")),\n}","preventionTips":["Allocate dedicated ports for the calibration API in deployment config","Treat repeated bind failures in health checks as a port-conflict incident, not a crash-loop bug","Never bind non-loopback without --token — the CLI itself warns the API would be drivable by anyone on the network"],"tags":["rust","network","http","bind","tcp"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}