How to kill a port that is in use
Apr 20 2024
//Updated Jun 22 2026
1 min read
We’ve all seen the dreaded EADDRINUSE error. No worries though, this is super easy to fix.
{ code: 'EADDRINUSE', errno: -48, syscall: 'listen', address: '::', port: 8080}There are a few ways to fix this:
tl;dr
‘npx kill-port’ is my goto, it is fast, easy to remember and does what you want it to on both all operating systems.
npx kill-port 8080But let’s go over all the other available options in case kill port does not work for you.
Unix-based systems (Linux, macOS)
lsof and kill
lsof -ti:8080 | xargs killfuser
fuser -k 8080/tcpnetstat and kill
sudo netstat -ltnp | grep ':8080' | awk '{print $7}' | sed 's/\/.\*//' | xargs killWindows
netstat and taskkill
netstat -aon | findstr :8080taskkill /F /PID <PID>Using PowerShell
Get-Process -Id (Get-NetTCPConnection -LocalPort 8080).OwningProcess | Stop-Process -ForceCross-platform tools
npx kill-port:
As mentioned before, this is a straightforward method that works across different operating systems.
npx kill-port 8080