I ran npm run dev on a Next.js 16 project and got this instead of a working server:
> next dev
⚠ Port 3000 is in use by process 968, using available port 3001 instead.
▲ Next.js 16.3.3 (Turbopack)
- Local: http://localhost:3001
- Network: http://192.168.1.20:3001
✓ Ready in 1414ms
⨯ Another next dev server is already running.
- Local: http://localhost:3000
- PID: 968
- Dir: C:\projects\my-app
- Log: .next\dev\logs\next-development.log
You can access the existing server at http://localhost:3000,
or run taskkill /PID 968 /F to stop it and start a new one.
The message is honest and the fix it suggests is right: an older next dev is still running for the same project, and you either use it or stop it. But on Windows the suggested command can fail, the old server is often one you can't see, and the tempting shortcut (deleting the lock file) makes things worse. Here's what the error actually checks and the fix that worked for me on Windows 11 with Next.js 16.3.3.
What "Another next dev server is already running" means
Next.js 16 keeps a lock file for the dev server at .next/dev/lock. When next dev starts, it tries to take that lock. If another process holds it, Next retries for about one second, prints the error and exits with code 1. The lock is not just an empty marker. While my server was running, the file contained:
{"pid":84408,"port":3000,"hostname":"localhost","appUrl":"http://localhost:3000","startedAt":1795587750098}
That's where the PID, the URL and the "Dir" line in the error come from. So the message doesn't guess. A process with that PID took the lock for this project folder and hasn't let go of it.
Two details worth knowing:
The check is per project folder, not per port. Two different projects can run
next devside by side. Two servers in the same folder can't, because they would write into the same.next/devdirectory.The port warning comes first. In my run, Next saw port 3000 busy, said it would use 3001, even printed "Ready", and only then hit the lock and quit. If you only read the top of the output, it looks like the server started on 3001. It didn't.
Why the old server is still running
In my case nothing was visible. No terminal showed a server, yet PID 968 held port 3000. The cause was an orphan: the npm run dev wrapper had been stopped, but the Node process it started (Next's start-server.js) kept running. That's the most common way to end up here. Other ways:
You started
npm run devin another terminal tab, VS Code's integrated terminal or a VS Code task, and forgot about it.A terminal window was closed or crashed, but the Node process survived.
A tool or script started the dev server in the background (a test runner, a "run" button, an AI coding agent).
The easy first step: open the URL from the error (http://localhost:3000). If your app loads, that old server is working fine and you can simply keep using it. You only need a new one if you changed environment variables, next.config or something else that's read at startup.
Fix: check the PID, then stop it
1. Make sure the PID is really your Next.js server
Before you force-kill anything, check what the PID is. On Windows, PowerShell shows the full command line:
# PowerShell: what is PID 968, really?
Get-CimInstance Win32_Process -Filter "ProcessId=968" | Select-Object -ExpandProperty CommandLine
# Output on my machine:
"C:\Program Files\nodejs\node.exe" C:\projects\my-app\node_modules\next\dist\server\lib\start-server.js
If it's node.exe running next\dist\server\lib\start-server.js inside your project folder, it's the stale dev server and safe to stop. If it's something else, don't force-kill it. Find out what it is first.
2. Stop it
:: Command Prompt or PowerShell
taskkill /PID 968 /F
# PowerShell only
Stop-Process -Id 968 -Force
Then run npm run dev again. Once the old process is gone, the operating system releases the lock and the new server starts normally on port 3000.
In Git Bash, the printed command fails
Next.js prints taskkill /PID 968 /F on Windows. Paste that into Git Bash and you get a confusing error, because Git Bash converts any argument that starts with a slash into a Windows path:
# Git Bash: the command Next.js prints fails
$ taskkill /PID 968 /F
ERROR: Invalid argument/option - 'C:/Program Files/Git/PID'.
# Any of these work
$ taskkill //PID 968 //F
$ taskkill -PID 968 -F
$ MSYS_NO_PATHCONV=1 taskkill /PID 968 /F
I tested all three working forms. The full explanation of that path conversion, plus netstat and PowerShell ways of finding who holds a port, is in my post on EADDRINUSE: address already in use :::3000 on Windows.
On macOS and Linux
# macOS / Linux (the command Next.js prints there)
kill 968
That's the command Next.js prints outside Windows. I've only tested the Windows side myself.
Don't delete .next/dev/lock
The lock is a file, so deleting it looks like the quick fix. I tried it to see what happens. While my server was still running, rm .next/dev/lock worked without any error on Windows. The next npm run dev then moved to port 3001, printed "Ready" and kept running. Now I had two dev servers for one project, both using the same .next/dev folder. That's the exact situation the lock exists to prevent. I stopped the test there, but I wouldn't trust compiled output written by two servers at once.
Deleting the whole .next folder doesn't fix the real problem either. The old process keeps running and keeps port 3000. Stop the process. The lock goes away with it.
Port in use vs server already running: which error do you get?
Same cause, different messages, depending on how you start the server:
| You run | Old server holds the lock | What you see |
|---|---|---|
| next dev | yes | Port warning, then "Another next dev server is already running" |
| next dev -p 3000 | yes or no | "Failed to start server", listen EADDRINUSE: address already in use :::3000 |
| next dev | no (lock deleted) | Port warning, server starts on 3001 (two servers) |
With a fixed port the port check fails first, so you get EADDRINUSE and never reach the lock check. Either way, the fix is the same: find the PID and stop it.
:: Windows: who is listening on 3000?
netstat -ano | findstr :3000
TCP 0.0.0.0:3000 0.0.0.0:0 LISTENING 968
What about next build?
Builds have their own lock. In Next.js 16.3.3's source, next build locks .next/lock and, if it's held, prints "Another next build process is already running", suggesting a build still in progress or one that didn't exit cleanly. I haven't hit that one myself. The dev lock lives in .next/dev, a separate folder.
One more trap from my own deploys: a next start left running while you build can write the old build's pages into the new .next folder. It's a different symptom (pages pointing at missing chunk files, the same thing behind a ChunkLoadError after a deploy), but the cause is the same: a forgotten server process. Before a production build, check that nothing is listening on your ports.
Quick checklist
Read the whole error. The PID and URL are in it, and the "using port 3001" line above it is misleading.
Open the URL. If the app works, you may not need a new server at all.
Check the PID's command line, then stop it:
taskkill /PID <pid> /F,Stop-Process -Id <pid> -Force, ortaskkill //PID <pid> //Fin Git Bash.Don't delete
.next/dev/lockwhile the old process lives. You'll get two servers.Closing a terminal or stopping
npmdoesn't always stop the Node child. Check the port afterwards.
Originally published on knowledgemarkg.com.
Top comments (0)