DEV Community

OneLineDev
OneLineDev

Posted on

Fix: 'Address Already in Use' (Kill Stuck Process on Any Port)

The Error

You start your local server (Node, Python, Go, Docker) and get stopped in your tracks:

Error: listen EADDRINUSE: address already in use :::3000
Enter fullscreen mode Exit fullscreen mode

(or bind: address already in use :8080)

Why It Happens

An orphaned background process or crashed terminal session didn't release the TCP socket. Your operating system prevents two applications from listening on the exact same port simultaneously.


⚡ Linux & macOS: Instant One-Liner Fix

Replace 3000 with your blocked port number:

npx kill-port 3000
Enter fullscreen mode Exit fullscreen mode

Native Terminal Alternatives (No Node required):

Option A (Using fuser):

fuser -k 3000/tcp
Enter fullscreen mode Exit fullscreen mode

Option B (Using lsof + kill):

kill -9 $(lsof -t -i:3000)
Enter fullscreen mode Exit fullscreen mode

⚡ Windows: Instant Fix

In PowerShell (One-Liner):

Stop-Process -Id (Get-NetTCPConnection -LocalPort 3000).OwningProcess -Force
Enter fullscreen mode Exit fullscreen mode

In CMD (Command Prompt):

  1. Find the Process ID (PID):
   netstat -ano | findstr :3000
Enter fullscreen mode Exit fullscreen mode
  1. Kill the process using the PID from the rightmost column:
   taskkill /PID <PID> /F
Enter fullscreen mode Exit fullscreen mode

Quick Tip

If you frequently run into this issue during development, install kill-port globally so you can blast any port from any terminal in 1 second:

npm install -g kill-port
kill-port 3000 8080 5000
Enter fullscreen mode Exit fullscreen mode

Top comments (0)