{"record":{"id":"0ac146a0e5df71d3","repo":"withastro/astro","slug":"ignore-lock-cannot-be-used-together-with-rea-0ac146","errorCode":null,"errorMessage":"`--ignore-lock` cannot be used together with ${reason}.\n\nBackground preview servers rely on the lock file so `astro preview stop`, `astro preview status`, and `astro preview logs` can find them.\nRun the preview server in the foreground to use --ignore-lock.","messagePattern":"`--ignore-lock` cannot be used together with (.+?)\\.\n\nBackground preview servers rely on the lock file so `astro preview stop`, `astro preview status`, and `astro preview logs` can find them\\.\nRun the preview server in the foreground to use --ignore-lock\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/astro/src/cli/preview/index.ts","lineNumber":94,"sourceCode":"\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.',\n\t\t\t\t'Run the preview server in the foreground to use --ignore-lock.',\n\t\t\t].join('\\n'),\n\t\t);\n\t}\n\n\tif (wantsBackground) {\n\t\tawait background({ flags, logger, config: previewServerCommand });\n\t\treturn;\n\t}\n\n\tif (subcommand) {\n\t\tlogger.error(\n\t\t\t'SKIP_FORMAT',\n\t\t\t`Unknown command: astro preview ${subcommand}\\n\\nRun \\`astro preview --help\\` to see available commands.`,","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/cli/preview/index.ts#L76-L112","documentation":"Error \"`--ignore-lock` cannot be used together with ${reason}.\n\nBackground preview servers rely on the lock file so `astro preview stop`, `astro preview status`, and `astro preview logs` can find them.\nRun the preview server in the foreground to use --ignore-lock.\" thrown in withastro/astro.","triggerScenarios":"Thrown at packages/astro/src/cli/preview/index.ts:94 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-14T00:17:10.932Z"}