clockworklabs/SpacetimeDB · error · anyhow::Error
Server already configured for host
Error message
Server already configured for host: {host} What it means
`Config::add_server` (backing `spacetime server add`) refuses to register a server whose host string is already present in the saved CLI configuration. Each host may be configured only once; the check runs after a nickname-ambiguity check, so a duplicate host fails even with a distinct nickname.
Solutions
- Remove the existing entry first: `spacetime server remove <existing-name-or-host>`
- Edit the existing entry instead: `spacetime server edit <server> ...`
- If a genuinely different server shares the host, distinguish it by port or scheme in the host string
Example fix
# before spacetime server add http://localhost:3000 mylocal # error: Server already configured for host: http://localhost:3000 # after spacetime server remove mylocal spacetime server add http://localhost:3000 mylocal
Defensive patterns
Strategy: validation
Validate before calling
// before adding, check the host is not already configured
if config.find_server(&host).is_ok() {
eprintln!("server for {host} already exists; edit or remove it first");
} else {
config.add_server(nickname, host, protocol, key)?;
} Try / catch
Match the anyhow error message for 'Server already configured for host' and branch to a remove-then-add or edit flow instead of failing the script.
Prevention
- Make provisioning scripts idempotent: check-before-add or remove-then-add
- Use one canonical host string (scheme + port) across all machines and scripts
When it happens
Trigger: Running `spacetime server add <host> ...` (or calling Config::add_server) with a host that `find_server` already resolves to an existing entry.
Common situations: Re-running provisioning scripts that add unconditionally; re-adding a server after reinstall while the CLI config file still holds it; adding the same local or maincloud host twice.
Related errors
- Host conflicts with saved configuration for server : ://
- Nickname conflicts with saved configuration for server : ://
- Server not specified and no default server configured.
- database is a required field in publish config
- Database ' ' is not in the config file. If you want to run…
AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20).
Data as JSON: /api/errors/e87f43269f30163c.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/config.rs:243
) -> 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}"))
}
fn default_host(&self) -> anyhow::Result<&str> {View on GitHub (pinned to 6dee26c6ef)