Astro Dev Already Running: Use --ignore-lock for a Second Server
Astro 7 added a lock file so a second astro dev process does not accidentally compete with the existing server. If you intentionally need two dev servers for the same project, start the extra one with --ignore-lock and give it a different port:
pnpm exec astro dev --ignore-lock --port 4322The flag bypasses the dev-server lock; it does not make two processes share one port or make the second process part of Astro’s background-server lifecycle. Astro 7.1 added the flag for this deliberate second-server workflow.
Decide whether you need a second server
First inspect the existing process:
pnpm exec astro dev statusIf the running server is yours and you only need to restart it, stop it through Astro’s lifecycle:
pnpm exec astro dev stoppnpm exec astro devIf a background server is stale, use the documented background lifecycle or --force path rather than creating an unmanaged copy. The Astro preview background guide covers the related preview commands; this article is about intentionally running multiple dev servers.
Use --ignore-lock when the first server must keep running. Typical reasons include comparing two configuration states, checking a different logging mode, or letting a short-lived tool inspect a second port without disturbing the main development session.
Use a different port explicitly
Astro can choose another available port in some server-start scenarios, but an explicit port makes the two endpoints obvious:
# Main terminalpnpm exec astro dev --port 4321
# Second terminalpnpm exec astro dev --ignore-lock --port 4322If port 4322 is already occupied, change it to a free port. --ignore-lock only skips Astro’s duplicate-project check; it does not override the operating system’s port binding rules.
When a script or browser automation checks the site, pass the second URL deliberately:
http://localhost:4322/Do not assume that a successful process start means the browser is looking at the new instance. Verify the response and the server output from the same terminal that launched it.
Understand what the lock controls
Astro’s dev lock records the running server’s information so commands such as astro dev status, astro dev stop, and astro dev logs can manage a background instance. The Astro CLI reference documents --ignore-lock as a way to start without checking or writing that lock.
The unmanaged second process therefore has an intentional limitation:
astro dev statusdoes not list it.astro dev stopdoes not stop it.astro dev logsdoes not provide its log lifecycle.--backgroundand--forcecannot be combined with--ignore-lock.
Keep the second process attached to its terminal when possible. Stop it with Ctrl+C, or terminate the exact process you started after confirming its PID. Do not remove the lock file to make the first process disappear; that can leave a live server unmanaged.
Do not use ignore-lock to hide a stale process
If Astro reports that a server is already running but you did not start it, check the status output and the process owner before bypassing the lock:
pnpm exec astro dev statusps -p <PID> -o pid=,ppid=,command=Replace <PID> with the actual PID from the status output. If the process is dead but the lock is stale, use Astro’s normal stop or restart path first. Delete a lock file only as a last-resort cleanup after you have verified that no server from the project is alive; a lock file is state, not the server itself.
If an AI coding agent automatically starts Astro in background mode, the normal lock is part of the coordination contract. Use --ignore-lock only for the intentional second foreground server, not as a default flag in every script.
Keep the second build and route assumptions clear
Both dev servers read the same source tree, but they can still differ in command-line flags, environment variables, and selected port. Write down what each instance is testing:
# Example: inspect a second configuration without changing the main processASTRO_LOG_LEVEL=debug pnpm exec astro dev \ --ignore-lock \ --port 4322Avoid changing files under test while comparing two instances unless the difference is intentional. If a configuration change affects generated routes or assets, refresh both browser tabs and record which port produced each result.
This server-management boundary is separate from static URL output. If the issue is a generated pagination link that lacks .html, see Astro pagination URLs with .html instead of adding another dev server.
Verify and clean up
Use a short checklist after starting the second server:
- Confirm the first and second commands use different ports.
- Request each URL and verify the expected project state.
- Check the terminal output to identify which process served a response.
- Stop the unmanaged second process with
Ctrl+C. - Use
astro dev statusto confirm the managed server is still the one you expect.
The practical rule is to treat --ignore-lock as a scoped escape hatch. It is useful for a deliberate second foreground server, but it also opts that process out of Astro’s lifecycle management.
FAQ
Q: What does Astro dev —ignore-lock do?
A: It starts a dev server without checking or writing the lock file Astro uses to detect another server for the same project. Use it with a different port when you intentionally need a second instance.
Q: Can I combine —ignore-lock with —background?
A: No. Astro’s CLI reference says --ignore-lock cannot be combined with --background or --force, because those modes rely on the lock file for process management.
Q: Why does astro dev status not show my second server?
A: A server started with --ignore-lock is deliberately unmanaged. status, stop, and logs do not track it; keep its terminal open and stop that process directly.
Q: Should I delete .astro/dev.json to fix an already-running error?
A: Not before checking the process. The lock file is only a record of server state. Confirm that no Astro server from the project is alive, then use the normal restart or cleanup path rather than deleting a live process’s coordination state.
References:
Astro 7.1: Full control over pagination URLs and dev servers
Report a typo or broken link, or suggest a related topic.