{"record":{"id":"87b4bb4e4bad2b16","repo":"ekzhang/bore","slug":"server-error-message","errorCode":null,"errorMessage":"server error: {message}","messagePattern":"server error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/client.rs","lineNumber":52,"sourceCode":"impl Client {\n    /// Create a new client.\n    pub async fn new(\n        local_host: &str,\n        local_port: u16,\n        to: &str,\n        port: u16,\n        secret: Option<&str>,\n    ) -> Result<Self> {\n        let mut stream = Delimited::new(connect_with_timeout(to, CONTROL_PORT).await?);\n        let auth = secret.map(Authenticator::new);\n        if let Some(auth) = &auth {\n            auth.client_handshake(&mut stream).await?;\n        }\n\n        stream.send(ClientMessage::Hello(port)).await?;\n        let remote_port = match stream.recv_timeout().await? {\n            Some(ServerMessage::Hello(remote_port)) => remote_port,\n            Some(ServerMessage::Error(message)) => bail!(\"server error: {message}\"),\n            Some(ServerMessage::Challenge(_)) => {\n                bail!(\"server requires authentication, but no client secret was provided\");\n            }\n            Some(_) => bail!(\"unexpected initial non-hello message\"),\n            None => bail!(\"unexpected EOF\"),\n        };\n        info!(remote_port, \"connected to server\");\n        info!(\"listening at {to}:{remote_port}\");\n\n        Ok(Client {\n            conn: Some(stream),\n            to: to.to_string(),\n            local_host: local_host.to_string(),\n            local_port,\n            remote_port,\n            auth,\n        })\n    }","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/ekzhang/bore/blob/00a735a89917642df62d84336a90d9476fa175b5/src/client.rs#L34-L70","documentation":"In `Client::new`, after the client sends `Hello`, the server responded with a `ServerMessage::Error` carrying a free-form `message` string, which is re-raised verbatim as `server error: {message}`. This is a pass-through of any application-level error the bore server reports after the initial handshake (e.g. port allocation failure).","triggerScenarios":"Server rejects the `Hello(port)` request: requested remote port is unavailable/in use, the user is not allowed that port, the local port is invalid per server rules, or a server-internal error occurs during connection setup.","commonSituations":"Requesting a specific remote port already taken by another tunnel; requesting a privileged or forbidden port blocked by server config (`--min-port`); server at capacity; stale server instance with stale state.","solutions":["Read the `{message}` suffix for the server's specific reason and fix accordingly.","Retry with a different remote port (or omit it to let the server assign one).","Check server logs and port-range configuration (`--min-port`) if requesting specific ports.","Verify the server is healthy/restart it if the error indicates internal failure."],"exampleFix":"// before\nbore local 3000 --to bore.example.com --port 22\n// after (let server pick an available remote port)\nbore local 3000 --to bore.example.com","handlingStrategy":"try-catch","validationCode":"// Probe the remote port's availability by handling the error message before final use\n// (no client-side pre-check exists; parse the server's reason instead)\nlet result = Client::new(...).await;\nif let Err(e) = &result {\n    if let Some(reason) = e.to_string().strip_prefix(\"server error: \") {\n        log::warn!(\"server rejected tunnel: {reason}\");\n    }\n}","typeGuard":null,"tryCatchPattern":"match Client::new(...).await {\n    Err(e) if e.to_string().starts_with(\"server error:\") => eprintln!(\"{}\", e), // show server's reason\n    other => other,\n}","preventionTips":["Pick remote ports you know are free, or omit --port to auto-assign.","Respect the server's --min-port range when requesting specific ports.","Monitor server capacity if running many tunnels."],"tags":["server","network","port-allocation"],"backgroundTag":"api-error-response","analyzedSha":"00a735a89917642df62d84336a90d9476fa175b5","analyzedAt":"2026-09-08T13:27:32.996Z","contentChangedAt":"2026-09-08T13:27:32.996Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}