clockworklabs/SpacetimeDB · error

Server host name is ambiguous with existing server nickname:

Error message

Server host name is ambiguous with existing server nickname: {nick}

What it means

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').

Source

Thrown at crates/cli/src/config.rs:241

        ecdsa_public_key: Option<String>,
        nickname: Option<String>,
    ) -> anyhow::Result<()> {
        if let Some(nickname) = &nickname
            && let Ok(cfg) = self.find_server(nickname)
        {
            anyhow::bail!(
                "Server nickname {} already in use: {}://{}",
                nickname,
                cfg.protocol,
                cfg.host,
            );
        }

        if let Ok(cfg) = self.find_server(&host) {
            if let Some(nick) = &cfg.nickname
                && nick == &host
            {
                anyhow::bail!("Server host name is ambiguous with existing server nickname: {nick}");
            }
            anyhow::bail!("Server already configured for host: {host}");
        }

        self.server_configs.push(ServerConfig {
            nickname,
            host,
            protocol,
            ecdsa_public_key,
        });
        Ok(())
    }

    fn host(&self, server: &str) -> anyhow::Result<&str> {
        self.find_server(server)
            .map(|cfg| cfg.host.as_ref())
            .with_context(|| format!("Cannot find hostname for unknown server: {server}"))
    }

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Rename the existing entry whose nickname collides (spacetime server remove <nick> and re-add under a new nickname)
  2. Use a fully-qualified hostname, IP, or port-bearing URL for the new server so it no longer equals the nickname string
  3. Audit spacetime server list for nickname/host overlap before adding

Example fix

# before
spacetime server add --url http://localhost:3000  # Error: ambiguous with existing server nickname: localhost

# after
spacetime server add dev --url http://127.0.0.1:3000
Defensive patterns

Strategy: validation

Validate before calling

# Refuse to add a host that collides with an existing nickname:
HOSTPART=$(printf '%s' "$URL" | sed -E 's#^[a-z]+://##; s#[:/].*$##')
if spacetime server list | awk '{print $1}' | grep -qx "${HOSTPART}"; then
  echo "host '${HOSTPART}' collides with an existing nickname" >&2; exit 2
fi
spacetime server add dev --url "$URL"

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/a392d098a049f24a. Report an issue: GitHub.