clockworklabs/SpacetimeDB · error

Database '{}' is not in the config file. If you want to run

Error message

Database '{}' is not in the config file. If you want to run against a database outside of the current project, pass --no-config.

What it means

The single-database variant of unknown_database_error: the supplied database name doesn't match the one database declared in spacetime.json. With exactly one candidate the message drops the list and keeps the same remedies — use the configured name, or --no-config for a database outside the project.

Source

Thrown at crates/cli/src/subcommands/db_arg_resolution.rs:51

#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct ResolvedDbArgs {
    pub database: String,
    pub server: Option<String>,
    pub remaining_args: Vec<String>,
}

/// Build an error for when the first positional arg doesn't match any configured database target.
fn unknown_database_error(db: &str, config_targets: &[ConfigDbTarget]) -> anyhow::Error {
    let known: Vec<&str> = config_targets.iter().map(|t| t.database.as_str()).collect();
    if known.len() > 1 {
        anyhow::anyhow!(
            "Multiple databases found in config: {}. Please specify which database to use, \
             or pass --no-config to use '{}' directly.",
            known.join(", "),
            db
        )
    } else {
        anyhow::anyhow!(
            "Database '{}' is not in the config file. \
             If you want to run against a database outside of the current project, pass --no-config.",
            db
        )
    }
}

pub(crate) fn load_config_db_targets(no_config: bool) -> anyhow::Result<Option<Vec<ConfigDbTarget>>> {
    if no_config {
        return Ok(None);
    }

    Ok(find_and_load_with_env(None)?
        .map(|loaded| {
            loaded
                .config
                .collect_all_targets_with_inheritance()
                .iter()

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Run the command with the database name from spacetime.json (or omit it to let the single entry resolve)
  2. Update spacetime.json if the intended database name changed there
  3. Pass --no-config to target a database not managed by this project's config

Example fix

# before (spacetime.json declares "database": "app-db")
spacetime logs database

# after
spacetime logs app-db
Defensive patterns

Strategy: validation

Validate before calling

# Single-database projects: read the real name from config
DB=$(jq -r '.databases[0].database // .modules[0].database' spacetime.json)
spacetime logs "$DB"

Type guard

fn is_configured_db(name: &str, targets: &[ConfigDbTarget]) -> bool {
    targets.iter().any(|t| t.database == name)
}

Try / catch

if stderr contains "is not in the config file" {
    // either correct the name from `spacetime.json` or re-run with --no-config for out-of-project databases
}

Prevention

When it happens

Trigger: `spacetime <cmd> <name>` inside a project whose spacetime.json declares exactly one database whose name differs from <name>.

Common situations: The database was renamed in spacetime.json during a refactor and scripts use the old name; using a historical or default name like 'database' instead of the configured one.

Related errors


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