How to find what is using a port
Identify the process listening on a port with ss, lsof and netstat, then free the port safely on Linux, macOS and Windows.
Beginner · about 4 min · Linux, Windows, macOS
"Port already in use" stops a server from starting. The fix is two steps: find the process ID holding the port, then decide whether to stop it or move your service to a different port.
What this guide covers
- Linux: list listening sockets with ss
- Linux/macOS: lsof shows the owning process
- Windows: netstat plus the PID
- Windows: resolve the PID to a program
- PowerShell: one command for the whole job
- Free the port
Common pitfalls covered
- Without sudo, ss and lsof hide processes owned by other users — you will see the port but no PID.
- Killing a system service to free a port often breaks something else; check the process name before you act.
- A port in TIME_WAIT is not in use by a process — wait, or enable SO_REUSEADDR in your server.
Questions answered
- How do I kill the process using port 3000?
- What replaced netstat on Linux?
- Why does the port stay busy after I stop my app?
This is a limited preview. The full walkthrough, command syntax and copy-ready examples are available to signed-in users.