Port already in use? Find which program is using it on Windows and Mac
One of the most common errors in development: you start a server and it says port 8080 is already in use (Address already in use). There are just two steps: find which program it is, then decide whether to stop it.
The examples use 8080; put in your own port number.
Windows
Command Prompt
netstat -ano | findstr :8080
On the “LISTENING” line, the number in the last column is the process ID (PID) holding the port. Then look up the program by its PID:
tasklist /fi "PID eq 1234"
You can also find it by the PID column under Details in Task Manager.
PowerShell
Get-NetTCPConnection -LocalPort 8080 | Select-Object LocalAddress, State, OwningProcess
Get-Process -Id 1234
Resource Monitor
Search the Start menu for “Resource Monitor”, then open Network → Listening Ports to see every port being listened on and its program.
Stopping it
Once you are sure it is your own program (say, a development server you forgot to stop), end it in Task Manager or run taskkill /PID 1234. Do not end system processes casually.
Mac
In Terminal, run:
lsof -nP -iTCP:8080 -sTCP:LISTEN
COMMAND is the program, PID its process ID. For UDP ports, use something like lsof -nP -iUDP:5353.
Once you are sure it is your own program, run kill 1234, or find it in Activity Monitor and quit it.
While you are there: is it open to your network?
The address it listens on decides who can connect:
- 127.0.0.1 or ::1: only this computer;
- 0.0.0.0 or ::: every network interface, so other devices on the same network can connect too.
On public networks such as cafés and airports, a development server open on every interface is worth a second look.
Seeing it in Hoardkin
Hoardkin’s Ports in use page lists every port being listened on:
- Port, program and PID at a glance, searchable by port, program or PID;
- Marked “On the network” or “This PC only”;
- End your own processes: Hoardkin asks first and warns that unsaved work may be lost; it will not end key system processes or other users’ processes.
The list is read only while the page is open; nothing watches in the background.
To remember fewer commands, download Hoardkin; it is free, for Windows and Mac.