{"record":{"id":"5270a6c1ed5fa858","repo":"zed-industries/zed","slug":"failed-to-bind-tcp-listener","errorCode":null,"errorMessage":"failed to bind TCP listener","messagePattern":"failed to bind TCP listener","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/collab/src/main.rs","lineNumber":66,"sourceCode":"                Some(\"collab\") => ServiceMode::Collab,\n                Some(\"api\") => ServiceMode::Api,\n                Some(\"all\") => ServiceMode::All,\n                _ => {\n                    return Err(anyhow!(\"usage: collab <version | serve <api|collab|all>>\"))?;\n                }\n            };\n\n            let config = envy::from_env::<Config>().expect(\"error loading config\");\n            init_tracing(&config);\n            init_panic_hook();\n\n            let mut app = Router::new()\n                .route(\"/\", get(handle_root))\n                .route(\"/healthz\", get(handle_liveness_probe))\n                .layer(Extension(mode));\n\n            let listener = TcpListener::bind(format!(\"0.0.0.0:{}\", config.http_port))\n                .expect(\"failed to bind TCP listener\");\n\n            let mut on_shutdown = None;\n\n            if mode.is_collab() || mode.is_api() {\n                setup_app_database(&config).await?;\n\n                let state = AppState::new(config, Executor::Production).await?;\n\n                if mode.is_collab() {\n                    let epoch = state\n                        .db\n                        .create_server(&state.config.zed_environment)\n                        .await?;\n                    let rpc_server = collab::rpc::Server::new(epoch, state.clone());\n                    rpc_server.start().await?;\n\n                    app = app.merge(collab::rpc::routes(rpc_server.clone()));\n","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/collab/src/main.rs#L48-L84","documentation":"Fires in collab's main when binding the axum Router's TCP listener fails, typically because the configured port is already in use or the address is not bindable (permissions, IPv6 unavailability). The collab service cannot serve requests without the listener.","triggerScenarios":"Thrown at crates/collab/src/main.rs:66 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check for another process already bound to the configured port (lsof/ss)","Change the port via configuration or stop the conflicting service","Verify the listen address is valid and permitted (e.g. CAP_NET_BIND_SERVICE for ports < 1024)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}