{"record":{"id":"27d708390fd19207","repo":"openai/codex","slug":"addrinuse","errorCode":"AddrInUse","errorMessage":"Unable to determine the server port","messagePattern":"Unable to determine the server port","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/login/src/server.rs","lineNumber":168,"sourceCode":"}\n\nimpl ShutdownHandle {\n    /// Signals the login loop to terminate.\n    pub fn shutdown(&self) {\n        self.shutdown_notify.notify_one();\n    }\n}\n\n/// Starts a local callback server and returns the browser auth URL.\npub fn run_login_server(opts: ServerOptions) -> io::Result<LoginServer> {\n    let pkce = generate_pkce();\n    let state = opts.force_state.clone().unwrap_or_else(generate_state);\n\n    let server = bind_server(opts.port)?;\n    let actual_port = match server.server_addr().to_ip() {\n        Some(addr) => addr.port(),\n        None => {\n            return Err(io::Error::new(\n                io::ErrorKind::AddrInUse,\n                \"Unable to determine the server port\",\n            ));\n        }\n    };\n    let server = Arc::new(server);\n\n    let redirect_uri = format!(\"http://localhost:{actual_port}/auth/callback\");\n    let auth_url = build_authorize_url(\n        &opts.issuer,\n        &opts.client_id,\n        &redirect_uri,\n        &pkce,\n        &state,\n        opts.forced_chatgpt_workspace_id.as_deref(),\n    );\n\n    if opts.open_browser {","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/login/src/server.rs#L150-L186","documentation":"Error \"Unable to determine the server port\" thrown in openai/codex.","triggerScenarios":"Thrown at codex-rs/login/src/server.rs:168 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}