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:
netstat -ano | findstr :3000taskkill /PID 12345 /FThe 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:
Get-NetTCPConnection -LocalPort 3000 -State Listen | Select-Object LocalPort, OwningProcessGet-Process -Id 12345Stop-Process -Id 12345 -ForceAdd /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.
The Moonpool way
Section titled “The Moonpool way”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:
{ "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
portstep still runs. - Moonpool refuses to kill a fixed list of shared Windows processes by port, such as Docker
Desktop’s backend,
svchostand the WSL host. For a Docker app usekillModecommandornone, neverport. 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. portmode kills whatever listens, including a copy you started by hand, so use it only for ports nothing else on the machine needs.
See also
Section titled “See also”- Fix EADDRINUSE and “Port 5173 is in use”
- Stop and restart
- App fields:
portandkillMode. - Two apps use the same port
Moonpool is free software from FasterDB