benbjohnson/litestream · error

database not found in config: %s

Error message

database not found in config: %s

What it means

When restoring via a config file (no -replica/-o URL given), loadFromConfig expands the database path and looks it up with config.DBConfig. If no database config entry matches the path, it returns 'database not found in config'. The path must match the configured db path exactly after environment expansion, so this is fundamentally a lookup-by-exact-path failure.

Source

Thrown at cmd/litestream/restore.go:341

	_, err = r.CalcRestoreTarget(ctx, *opt)
	return r, err
}

// loadFromConfig returns a replica & updates the restore options from a DB reference.
func (c *RestoreCommand) loadFromConfig(_ context.Context, dbPath, configPath string, expandEnv, ifDBNotExists bool, opt *litestream.RestoreOptions) (*litestream.Replica, error) {
	// Load configuration.
	config, err := ReadConfigFile(configPath, expandEnv)
	if err != nil {
		return nil, err
	}

	// Lookup database from configuration file by path.
	if dbPath, err = expand(dbPath); err != nil {
		return nil, err
	}
	dbConfig := config.DBConfig(dbPath)
	if dbConfig == nil {
		return nil, fmt.Errorf("database not found in config: %s", dbPath)
	}
	db, err := NewDBFromConfig(dbConfig)
	if err != nil {
		return nil, err
	}

	// Restore into original database path if not specified.
	if opt.OutputPath == "" {
		opt.OutputPath = dbPath
	}

	// Exit successfully if the output file already exists.
	if _, err := os.Stat(opt.OutputPath); !os.IsNotExist(err) && ifDBNotExists {
		return nil, errSkipDBExists
	}

	return db.Replica, nil
}

View on GitHub (pinned to 4ed7a308f6)

Solutions

  1. Run `litestream databases -config /etc/litestream.yml` to list the exact db paths the config knows and copy one verbatim
  2. Use the absolute, symlink-resolved path exactly as it appears in the config file
  3. Check that any env vars or $PID placeholders used in the config resolve the same way here
  4. Verify you are pointing at the same config file used when litestream ran (`-config` flag)

Example fix

# before
litestream restore ./app/db.sqlite -config /etc/litestream.yml
# error: database not found in config: ./app/db.sqlite

# after — use the exact absolute path from the config
litestream restore /var/lib/app/db.sqlite -config /etc/litestream.yml
Defensive patterns

Strategy: validation

Validate before calling

// Go: check the path exists in config before calling restore
if config.DBConfig(expand(dbPath)) == nil {
	return fmt.Errorf("db path %s not in config; run: litestream databases -config %s", dbPath, cfgFile)
}
// Shell pre-flight:
// litestream databases -config /etc/litestream.yml | grep -Fx "$(readlink -f $DBPATH)"

Prevention

When it happens

Trigger: Running `litestream restore <dbpath> -config /etc/litestream.yml` where <dbpath> is not present as a `dbs` entry in the config file, or the given path differs from the configured one (relative vs absolute path, trailing slash, unexpanded symlinks, different hostname placeholders like $PID).

Common situations: Passing a relative path while the config lists an absolute path (or vice versa); typos in the db path; the config file references a different host's config; the database was removed from the config after the replica was set up; env vars used in the config are not set in the shell running restore.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06). Data as JSON: /api/errors/ce0fde889852a9b1. Report an issue: GitHub.