Linux Top Query

How to Kill a Process on Port 8000, 3000 or 8080 in Linux & Mac

Error Message
Error: listen EADDRINUSE: address already in use :::3000 OSError: [Errno 48] Address already in use
Quick Fix
lsof -ti:3000 | xargs kill -9

Why Does This Happen?

A previously running web server (Django, Node.js, Flask, etc.) did not shut down cleanly and a zombie process is still holding the TCP port open.

Step-by-Step Solution

1
Method 1: One-liner (lsof + kill)
Find the PID listening on the port and send an immediate SIGKILL:
Terminal / Code
# For port 3000:
lsof -ti:3000 | xargs kill -9

# For port 8000 (Django):
lsof -ti:8000 | xargs kill -9
Prepend sudo if you get a permission denied error.
2
Method 2: Inspect first, then kill
See what process is using the port before terminating it:
Terminal / Code
lsof -i :3000
# Note the PID from the output
kill -9 <PID>
Safer — lets you verify you are killing the right process.
3
Method 3: Using fuser (Ubuntu / Debian / CentOS)
fuser is a built-in Linux utility for socket management:
Terminal / Code
fuser 8000/tcp
fuser -k 8000/tcp
Add -9 flag for forceful kill: fuser -k -9 8000/tcp

Common Mistakes to Avoid

Killing PID 1 or system daemon processes. Always check the process name first.
Closing the terminal without Ctrl+C — this often leaves Node/Python processes running in the background.

Frequently Asked Questions

How do I do this on Windows?
Open PowerShell as Admin: netstat -ano | findstr :3000 — note the PID, then: taskkill /PID <PID> /F

Learn to Write Code That Doesn't Break

DoxaTech Hub's 10-month programme teaches you Git internals, Linux systems, C, Python, SQL, Docker, and React from first principles — so you spend less time fixing errors and more time shipping.

Start Learning →