Fix Astro dev port conflicts and stale pages
A common Astro pain point during active edits is this pattern:
- dev server jumps to a new port (
4321,4322,57635, etc.) - one page shows old content while another shows new content
- image paths behave inconsistently
This is almost always multiple stale dev processes + cached generated state.
One-command reset flow
Run this from project root:
pkill -f "astro dev" || true
pkill -f "npm run dev" || true
rm -rf .astro
npm run dev
Then use only the fresh URL Astro prints (usually http://localhost:4321).
Why this fixes it
pkillremoves old servers serving old state- deleting
.astroforces content/types regeneration - starting one server gives a single source of truth
Verify you are on the right server
- Open the newly printed local URL
- Hard refresh once
- Confirm your latest content is visible
If old pages still appear, you are likely browsing a stale port tab.
Optional hardening
If this happens often, use a consistent startup habit:
- close old terminal sessions first
- start only one
npm run dev - avoid running dev from multiple shells
Small discipline here saves a lot of debugging time later.