How to Kill a Process Running on a Specific Port

Find what is using a port and kill it safely. Complete guide for macOS, Linux, and Windows with one-command and manual methods.

Updated April 2026 4 min read

The Quick Way: One Command

With portrm, killing a process on any port takes one command:

$ ptrm fix 3000

  Port 3000 in use
  Node.js (PID 7821) - Express server
  SAFE - dev server, safe to kill

  Fix port 3000? [Y/n] Y
  Killed PID 7821 (SIGTERM)
  Port 3000 is now free

Skip confirmation: ptrm fix 3000 -y

Kill and restart: ptrm fix 3000 --run "npm start"

Kill multiple ports: ptrm fix 3000 8080 5432 -y

Install: npm install -g portrm or brew install abhishekayu/tap/portrm

macOS: Find and Kill Process on Port

Find what is using a port

$ lsof -i :3000
COMMAND  PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
node    7821   user   23u  IPv6 0x...  0t0      TCP *:3000 (LISTEN)

Or get just the PID:

$ lsof -ti :3000
7821

Kill the process

$ kill -9 $(lsof -ti :3000)

Or step by step:

$ kill 7821       # graceful (SIGTERM)
$ kill -9 7821    # force (SIGKILL) if SIGTERM fails

Linux: Find and Kill Process on Port

Using lsof

$ lsof -i :3000
$ kill -9 $(lsof -ti :3000)

Using fuser

$ fuser 3000/tcp           # shows PID
$ fuser -k 3000/tcp        # kills it

Using ss + kill

$ ss -tlnp | grep :3000
LISTEN  0  511  *:3000  *:*  users:(("node",pid=7821,fd=23))
$ kill -9 7821

Windows: Find and Kill Process on Port

> netstat -ano | findstr :3000
  TCP    0.0.0.0:3000    0.0.0.0:0    LISTENING    7821

> taskkill /PID 7821 /F

PowerShell alternative:

> Get-NetTCPConnection -LocalPort 3000 | Select-Object OwningProcess
> Stop-Process -Id 7821 -Force

Common Ports and What Uses Them

PortCommon ServiceKill Command
3000React, Next.js, Expressptrm fix 3000
3001React (alternate)ptrm fix 3001
5000Flask, .NETptrm fix 5000
5173Viteptrm fix 5173
8000Django, PHPptrm fix 8000
8080Java, Spring, Alt HTTPptrm fix 8080
5432PostgreSQLptrm fix 5432 (warns!)
6379Redisptrm fix 6379 (warns!)
27017MongoDBptrm fix 27017 (warns!)

Why Safe Kill Matters

Blindly running kill -9 is dangerous. It sends SIGKILL which:

portrm solves this with a 3-tier safety system:

Kill port processes the safe way

portrm identifies services, checks safety, and does graceful shutdown. One command.