{"record":{"id":"2ab6b22a40b2391d","repo":"withastro/astro","slug":"force-and-ignore-lock-cannot-be-used-toget","errorCode":null,"errorMessage":"`--force` and `--ignore-lock` cannot be used together.\n\n`--force` replaces the existing preview server; `--ignore-lock` starts a new one alongside it without touching the lock file. Choose one.","messagePattern":"`--force` and `--ignore-lock` cannot be used together\\.\n\n`--force` replaces the existing preview server; `--ignore-lock` starts a new one alongside it without touching the lock file\\. Choose one\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/astro/src/cli/preview/index.ts","lineNumber":80,"sourceCode":"\tif (subcommand === 'stop') {\n\t\tawait stop({ flags, logger, config: previewServerCommand });\n\t\treturn;\n\t}\n\n\tif (subcommand === 'status') {\n\t\tawait status({ flags, logger, config: previewServerCommand });\n\t\treturn;\n\t}\n\n\tif (subcommand === 'logs') {\n\t\tawait logs({ flags, logger, config: previewServerCommand });\n\t\treturn;\n\t}\n\n\t// Reject conflicting flag combinations up front, before starting anything.\n\tif (ignoreLock) {\n\t\tif (flags.force) {\n\t\t\tthrow new Error(\n\t\t\t\t[\n\t\t\t\t\t'`--force` and `--ignore-lock` cannot be used together.',\n\t\t\t\t\t'',\n\t\t\t\t\t'`--force` replaces the existing preview server; `--ignore-lock` starts a new one alongside it without touching the lock file. Choose one.',\n\t\t\t\t].join('\\n'),\n\t\t\t);\n\t\t}\n\t}\n\n\tif (ignoreLock && wantsBackground) {\n\t\tconst reason = flags.background\n\t\t\t? '`--background`'\n\t\t\t: 'an auto-detected AI agent environment, which runs the preview server in the background automatically';\n\t\tthrow new Error(\n\t\t\t[\n\t\t\t\t`\\`--ignore-lock\\` cannot be used together with ${reason}.`,\n\t\t\t\t'',\n\t\t\t\t'Background preview servers rely on the lock file so `astro preview stop`, `astro preview status`, and `astro preview logs` can find them.',","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/cli/preview/index.ts#L62-L98","documentation":"Error \"`--force` and `--ignore-lock` cannot be used together.\n\n`--force` replaces the existing preview server; `--ignore-lock` starts a new one alongside it without touching the lock file. Choose one.\" thrown in withastro/astro.","triggerScenarios":"Thrown at packages/astro/src/cli/preview/index.ts:80 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-09-09T03:35:40.650Z","contentChangedAt":"2026-09-09T03:35:40.650Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}