clockworklabs/SpacetimeDB · error · anyhow::Error

You need to be logged in as the owner of

Error message

You need to be logged in as the owner of {name} to publish to {name}

What it means

The server answered the publish request with PublishResult::PermissionDenied: the target database name is registered to a different identity. The CLI then checks whether it is acting anonymously (--anonymous flag or no saved login token); in that case it bails with this message instead of the 'not registered to the identity you provided' error shown to logged-in users. The intent is to distinguish 'you have no identity at all' from 'wrong identity'.

Solutions

  1. Run `spacetime login` on this machine/server and retry the publish.
  2. Verify you are on the intended server: `spacetime server list`, and re-run with `--server <name>` if needed.
  3. If you do not own the name, publish under a name/domain you own (the logged-in branch of this same code even suggests a domain prefix derived from your identity).
  4. Remove `--anonymous` from scripts, aliases, and command config.

Example fix

# before
spacetime publish mydb --anonymous
# after
spacetime login
spacetime publish mydb
Defensive patterns

Strategy: validation

Validate before calling

# Ensure credentials exist before publishing (idempotent)
spacetime login
spacetime publish mydb
# And drop --anonymous from every scripted invocation

Try / catch

If wrapping the CLI: on failure, if stderr matches "You need to be logged in as the owner", run `spacetime login` once and retry the publish a single time

Prevention

When it happens

Trigger: `spacetime publish <name>` where <name> already exists on that server and is owned by another identity, combined with anon_identity=true (--anonymous passed, or the command config sets anonymous, or no spacetimedb token is saved and login was skipped via --yes=skip-login).

Common situations: Fresh machine/container/CI with no `spacetime login` credentials; name collision with someone else's database on maincloud; publishing to the wrong server where your account does not own the name; scripts carrying a stray --anonymous flag.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@eddf9f5014 (2026-08-20). Data as JSON: /api/errors/2acd1ae14de91e86. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/subcommands/publish.rs:804

                let op = match op {
                    PublishOp::Created => "Created new",
                    PublishOp::Updated => "Updated",
                };
                if let Some(ref domain) = domain {
                    println!("{op} database with name: {domain}, identity: {database_identity}");
                } else {
                    println!("{op} database with identity: {database_identity}");
                }

                if is_maincloud_host(&database_host)
                    && let Some(domain) = domain.as_ref()
                {
                    println!("Dashboard: https://spacetimedb.com/{}", domain.as_ref());
                }
            }
            PublishResult::PermissionDenied { name } => {
                if anon_identity {
                    anyhow::bail!("You need to be logged in as the owner of {name} to publish to {name}",);
                }
                // If we're not in the `anon_identity` case, then we have already forced the user to log in above (using `get_auth_header`), so this should be safe to unwrap.
                let token = config.spacetimedb_token().unwrap();
                let identity = decode_identity(token)?;
                //TODO(jdetter): Have a nice name generator here, instead of using some abstract characters
                // we should perhaps generate fun names like 'green-fire-dragon' instead
                let suggested_tld: String = identity.chars().take(12).collect();
                return Err(anyhow::anyhow!(
                    "The database {name} is not registered to the identity you provided.\n\
                    We suggest you push to either a domain owned by you, or a new domain like:\n\
                    \tspacetime publish {suggested_tld}\n",
                ));
            }
        }
    }

    Ok(())
}

View on GitHub (pinned to eddf9f5014)