Skip to content

Find and kill the process using a port on Windows (3000, 5173, 8080)

When a dev server fails with a port already in use, something else is listening on that port. In Command Prompt, list listeners with the owning process ID, then kill it:

Terminal window
netstat -ano | findstr :3000
taskkill /PID 12345 /F

The last column of the LISTENING row is the PID (findstr :3000 also matches :30001, so read the local address). tasklist /FI "PID eq 12345" shows which program it is. In PowerShell the same lookup is:

Terminal window
Get-NetTCPConnection -LocalPort 3000 -State Listen | Select-Object LocalPort, OwningProcess
Get-Process -Id 12345
Stop-Process -Id 12345 -Force

Add /T to taskkill to end the process’s children as well. Processes owned by another user or by the system may need an elevated (administrator) window.

For an app you run through Moonpool, you do not look the PID up. Give the app a port, and Stop frees it. For a web app that is the default killMode, written out here:

apps.json
{
"id": "api",
"name": "API",
"group": "Web apps",
"type": "web",
"cwd": "C:\\code\\api",
"command": "npm start",
"port": 3000,
"env": { "PORT": "3000" },
"killMode": "port"
}

Stop first ends the terminal Moonpool started, then force-kills whatever is still listening on port. On Windows that is the same lookup as above (Get-NetTCPConnection -LocalPort <port> -State Listen), followed by taskkill /PID <pid> /T /F for each owner.

  • If something you did not start is holding the port, Moonpool shows the app as running but not “managed by Moonpool”. Press Stop on it: the port step still runs.
  • Moonpool refuses to kill a fixed list of shared Windows processes by port, such as Docker Desktop’s backend, svchost and the WSL host. For a Docker app use killMode command or none, never port. See Docker apps on Windows.
  • This only works for ports of apps listed in apps.json. For any other port, use the commands at the top.
  • port mode kills whatever listens, including a copy you started by hand, so use it only for ports nothing else on the machine needs.

Moonpool is free software from FasterDB