Port 4321 Is in Use: Why Is My Astro Site on Port 4322?
Astro says Port 4321 is in use, trying another one, and opens on 4322. Something else is using the port. Here's what that means and how to get 4321 back.
Tested on Astro 7.4

Your site is on port 4322 because something else is already using port 4321. Often, it’s another Astro dev server you forgot to stop. Astro doesn’t crash. It says Port 4321 is in use, trying another one... and picks the next free number. Open the new address, or stop the old server to get 4321 back.
Why it happens
A port is like a door number on your computer. Astro uses door 4321 by default. Only one program can use a door at a time.
If 4321 is taken, Astro tries 4322, then 4323, and so on. It uses the first free one.
We tested this on Astro 7.4. Our computer already had dev servers open on 4321 to 4324. Then we started a fresh project:
$ npm run dev
[vite] Port 4321 is in use, trying another one...
[vite] Port 4322 is in use, trying another one...
[vite] Port 4323 is in use, trying another one...
[vite] Port 4324 is in use, trying another one...
astro v7.4.7 ready in 146 ms
┃ Local http://localhost:4325/
┃ Network use --host to exposeWe cut out the times and a few extra lines. So the site opened at localhost:4325. Look at the line that says Local. That’s always the right address.
$ npm run dev
Another astro dev server is already running.
URL: http://localhost:4325
PID: 2664
Run `astro dev stop` to stop it, or use `astro dev --force` to replace it.How to fix it
You don’t have to fix anything. Your site works fine on 4322. But if you want 4321 back, here’s how.
- Find the old terminal window. Look for another terminal tab that’s still running
npm run dev. Click in it and pressCtrlandCto stop it. - Stop it from the project folder. If you can’t find the window, go to that project in a terminal and run
npx astro dev stop. We ran it, and it saidStopped dev server (pid 1719). - Start again. Run
npm run dev. Astro should now saylocalhost:4321.
Want to pick your own port instead? Add --port and a number:
$ npx astro dev --port 4500
astro v7.4.7 ready in 164 ms
┃ Local http://localhost:4500/Still stuck?
- If the page at the new address is blank or broken, the port isn’t the problem. Read the error in your terminal.
- Paste the full terminal output into an AI. Our guide on fixing Astro errors with AI shows what to say.
- Ask in our community.
Where to go next
- How to fix the most common Astro errors for other errors you might see.
- How to fix astro: command not found if the dev server won’t start at all.
Frequently asked questions
Is it bad if my site runs on port 4322?
No. Your site works the same on any port. Just open the address Astro shows you. The only problem is an old server still running somewhere.
What does Another astro dev server is already running mean?
You started the dev server twice in the same project. Astro won't start a second one. Run npx astro dev stop to stop the old one, then start again.
How do I pick my own port?
Add --port and a number. For example, npx astro dev --port 4500 opens your site at localhost:4500.
Stuck on a step?
Check the common errors guide, look up a word in the glossary, or ask the friendly people in the official Astro and EmDash Discords. How to ask so people can help.