{"record":{"id":"a392d098a049f24a","repo":"clockworklabs/SpacetimeDB","slug":"server-host-name-is-ambiguous-with-existing-server","errorCode":null,"errorMessage":"Server host name is ambiguous with existing server nickname: {nick}","messagePattern":"Server host name is ambiguous with existing server nickname: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/config.rs","lineNumber":241,"sourceCode":"        ecdsa_public_key: Option<String>,\n        nickname: Option<String>,\n    ) -> anyhow::Result<()> {\n        if let Some(nickname) = &nickname\n            && let Ok(cfg) = self.find_server(nickname)\n        {\n            anyhow::bail!(\n                \"Server nickname {} already in use: {}://{}\",\n                nickname,\n                cfg.protocol,\n                cfg.host,\n            );\n        }\n\n        if let Ok(cfg) = self.find_server(&host) {\n            if let Some(nick) = &cfg.nickname\n                && nick == &host\n            {\n                anyhow::bail!(\"Server host name is ambiguous with existing server nickname: {nick}\");\n            }\n            anyhow::bail!(\"Server already configured for host: {host}\");\n        }\n\n        self.server_configs.push(ServerConfig {\n            nickname,\n            host,\n            protocol,\n            ecdsa_public_key,\n        });\n        Ok(())\n    }\n\n    fn host(&self, server: &str) -> anyhow::Result<&str> {\n        self.find_server(server)\n            .map(|cfg| cfg.host.as_ref())\n            .with_context(|| format!(\"Cannot find hostname for unknown server: {server}\"))\n    }","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/config.rs#L223-L259","documentation":"add_server also rejects a host that equals an existing server's nickname (crates/cli/src/config.rs:241). Because find_server matches both nickname and host, such an entry would make lookups ambiguous; the immediately following line shows the sibling case where the host itself is already configured ('Server already configured for host').","triggerScenarios":"Running spacetime server add --url http://localhost ... (or any bare host) where that exact string is already the nickname of a saved server; commonly happens with 'localhost' or short internal hostnames.","commonSituations":"Registering 'localhost' as a nickname in one entry then adding a bare-host localhost entry later; team config imports where nicknames and hostnames overlap; provisioning scripts that mix naming schemes.","solutions":["Rename the existing entry whose nickname collides (spacetime server remove <nick> and re-add under a new nickname)","Use a fully-qualified hostname, IP, or port-bearing URL for the new server so it no longer equals the nickname string","Audit spacetime server list for nickname/host overlap before adding"],"exampleFix":"# before\nspacetime server add --url http://localhost:3000  # Error: ambiguous with existing server nickname: localhost\n\n# after\nspacetime server add dev --url http://127.0.0.1:3000","handlingStrategy":"validation","validationCode":"# Refuse to add a host that collides with an existing nickname:\nHOSTPART=$(printf '%s' \"$URL\" | sed -E 's#^[a-z]+://##; s#[:/].*$##')\nif spacetime server list | awk '{print $1}' | grep -qx \"${HOSTPART}\"; then\n  echo \"host '${HOSTPART}' collides with an existing nickname\" >&2; exit 2\nfi\nspacetime server add dev --url \"$URL\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use fully-qualified hostnames or explicit IPs/ports instead of bare short names","Keep nicknames clearly distinct from hostnames by convention (e.g. nickname 'local', host '127.0.0.1:3000')","Audit spacetime server list for nickname/host overlaps when merging configs"],"tags":["cli","configuration","server","naming-conflict","spacetimedb"],"backgroundTag":"ambiguous-server-name","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}