{"record":{"id":"56e6e951487aed38","repo":"zed-industries/zed","slug":"oauth-callback-port-addr-remained-in-use-after","errorCode":null,"errorMessage":"OAuth callback port {addr} remained in use after {BIND_MAX_ATTEMPTS} attempts","messagePattern":"OAuth callback port (.+?) remained in use after (.+?) attempts","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/oauth_callback_server/src/oauth_callback_server.rs","lineNumber":452,"sourceCode":"                    if !cancel_attempted {\n                        cancel_attempted = true;\n                        if let Err(cancel_err) = send_cancel_request(host, port) {\n                            log::warn!(\n                                \"Failed to cancel previous OAuth callback server on {addr}: {cancel_err}\"\n                            );\n                        }\n                    }\n\n                    last_err = Some(anyhow!(err));\n                    std::thread::sleep(BIND_RETRY_DELAY);\n                }\n            }\n        }\n\n        Err(last_err\n            .unwrap_or_else(|| anyhow!(\"unknown bind error\"))\n            .context(format!(\n                \"OAuth callback port {addr} remained in use after {BIND_MAX_ATTEMPTS} attempts\"\n            )))\n    }\n\n    /// Sends `GET /cancel` to a listener on `host:port`, asking it to shut down.\n    ///\n    /// Best-effort: errors here are surfaced to the caller for logging but do\n    /// not block the subsequent rebind attempt.\n    fn send_cancel_request(host: &str, port: u16) -> std::io::Result<()> {\n        use std::io::{Read as _, Write as _};\n        use std::net::{TcpStream, ToSocketAddrs as _};\n\n        let addr = format!(\"{host}:{port}\")\n            .to_socket_addrs()?\n            .next()\n            .ok_or_else(|| {\n                std::io::Error::new(\n                    std::io::ErrorKind::InvalidInput,\n                    format!(\"could not resolve {host}:{port}\"),","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/oauth_callback_server/src/oauth_callback_server.rs#L434-L470","documentation":"Exhaustion error in try_bind_with_cancel: after BIND_MAX_ATTEMPTS (with cancel requests and BIND_RETRY_DELAY between tries) the OAuth callback port was still occupied, so the last bind error is returned and the server cannot start.","triggerScenarios":"Thrown at crates/oauth_callback_server/src/oauth_callback_server.rs:452 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Find and terminate the stale process holding the port (e.g. leftover Zed/localhost listener)","Wait a moment and retry the sign-in","Use a different port via the callback server config"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}