{"record":{"id":"ce0fde889852a9b1","repo":"benbjohnson/litestream","slug":"database-not-found-in-config-s","errorCode":null,"errorMessage":"database not found in config: %s","messagePattern":"database not found in config: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/restore.go","lineNumber":341,"sourceCode":"\t_, err = r.CalcRestoreTarget(ctx, *opt)\n\treturn r, err\n}\n\n// loadFromConfig returns a replica & updates the restore options from a DB reference.\nfunc (c *RestoreCommand) loadFromConfig(_ context.Context, dbPath, configPath string, expandEnv, ifDBNotExists bool, opt *litestream.RestoreOptions) (*litestream.Replica, error) {\n\t// Load configuration.\n\tconfig, err := ReadConfigFile(configPath, expandEnv)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Lookup database from configuration file by path.\n\tif dbPath, err = expand(dbPath); err != nil {\n\t\treturn nil, err\n\t}\n\tdbConfig := config.DBConfig(dbPath)\n\tif dbConfig == nil {\n\t\treturn nil, fmt.Errorf(\"database not found in config: %s\", dbPath)\n\t}\n\tdb, err := NewDBFromConfig(dbConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Restore into original database path if not specified.\n\tif opt.OutputPath == \"\" {\n\t\topt.OutputPath = dbPath\n\t}\n\n\t// Exit successfully if the output file already exists.\n\tif _, err := os.Stat(opt.OutputPath); !os.IsNotExist(err) && ifDBNotExists {\n\t\treturn nil, errSkipDBExists\n\t}\n\n\treturn db.Replica, nil\n}","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/restore.go#L323-L359","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Run `litestream databases -config /etc/litestream.yml` to list the exact db paths the config knows and copy one verbatim","Use the absolute, symlink-resolved path exactly as it appears in the config file","Check that any env vars or $PID placeholders used in the config resolve the same way here","Verify you are pointing at the same config file used when litestream ran (`-config` flag)"],"exampleFix":"# before\nlitestream restore ./app/db.sqlite -config /etc/litestream.yml\n# error: database not found in config: ./app/db.sqlite\n\n# after — use the exact absolute path from the config\nlitestream restore /var/lib/app/db.sqlite -config /etc/litestream.yml","handlingStrategy":"validation","validationCode":"// Go: check the path exists in config before calling restore\nif config.DBConfig(expand(dbPath)) == nil {\n\treturn fmt.Errorf(\"db path %s not in config; run: litestream databases -config %s\", dbPath, cfgFile)\n}\n// Shell pre-flight:\n// litestream databases -config /etc/litestream.yml | grep -Fx \"$(readlink -f $DBPATH)\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass the absolute path exactly as listed in the config file","List known dbs with `litestream databases -config ...` before restoring","Use the same -config file that the running litestream instance uses","Resolve symlinks (readlink -f) before passing the path"],"tags":["config","restore","cli","path"],"backgroundTag":"resource-not-found","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}