Programming

"Another next dev server is already running": How to Fix It (Next.js 16)

Next.js 16 refused to start with "Another next dev server is already running". What the .next/dev/lock file holds, why an invisible orphan server causes it, the Windows fix (and why the printed taskkill fails in Git Bash), and what happened when I deleted the lock.

Kausar RazaBy 6 min read11 views
Share:
Another next dev server is already running: Next.js 16 dev lock error and how to fix it
  • Web Development
  • Windows
  • Next.js
  • Node.js
Available for projects

Need help with this?

I build and fix business websites - fast, mobile-first and built to bring enquiries.

  • Fixed quote, no surprises
  • Speed & SEO built in
  • Reply within a few hours
Get a free quoteChat on WhatsApp

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 dev side by side. Two servers in the same folder can't, because they would write into the same .next/dev directory.
  • 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 dev in 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 runOld server holds the lockWhat you see
next devyesPort warning, then "Another next dev server is already running"
next dev -p 3000yes or no"Failed to start server", listen EADDRINUSE: address already in use :::3000
next devno (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, or taskkill //PID <pid> //F in Git Bash.
  • Don't delete .next/dev/lock while the old process lives. You'll get two servers.
  • Closing a terminal or stopping npm doesn't always stop the Node child. Check the port afterwards.

Frequently asked questions

What does "Another next dev server is already running" mean?
Next.js 16 found its dev lock (.next/dev/lock) held by another process for the same project folder. Only one next dev may run per project, so the new one exits. The error shows the old server's URL and PID: use that server, or stop the PID and start again.
How do I fix "Another next dev server is already running" on Windows?
Take the PID from the error, check it is node.exe running Next's start-server.js (Get-CimInstance Win32_Process -Filter "ProcessId=" in PowerShell), then stop it with taskkill /PID /F or Stop-Process -Id -Force, and run npm run dev again.
Why does taskkill /PID fail in Git Bash?
Git Bash turns arguments starting with a slash into Windows paths, so /PID becomes C:/Program Files/Git/PID and taskkill reports 'Invalid argument/option'. Use taskkill //PID //F, taskkill -PID -F, or MSYS_NO_PATHCONV=1 taskkill /PID /F.
Can I just delete .next/dev/lock?
Don't. When I deleted it while the old server was still running, a second next dev started on port 3001, so two dev servers shared one .next/dev folder. The old process also keeps the port. Stop the process and the lock is released with it.
Why is there a dev server running when no terminal shows one?
Usually the npm wrapper was stopped or the terminal closed, but the Node child process kept running. It can also be a VS Code task, another terminal tab, or a tool that started the server in the background. netstat -ano | findstr :3000 shows the PID holding the port.
Why did Next.js say it would use port 3001 and then exit?
Plain next dev first sees port 3000 busy and switches to 3001, then tries to take the project's dev lock. The old server still holds the lock, so the new one exits even though it printed Ready. With next dev -p 3000 you get listen EADDRINUSE instead.
Can two Next.js projects run next dev at the same time?
Yes. The lock is per project folder (.next/dev inside each project), not global. Two different projects only need different ports, and plain next dev picks the next free port by itself.

Join the conversation

No comments yet — be the first to share what you think.

Leave a comment

Never published.

Optional.

Keep reading

Related articles

View all