Skip to main content
⚑ OpenDevDocs
Linux
linuxlinuxReferenceBeginner

Kill Process on Port (lsof + kill)

Find and terminate any process holding a specific TCP/UDP port on Linux or macOS.

Verified: 2026-09-30
Tested on:bash 5.x, zsh 5.x
Platforms:
linuxmacos
#linux#macos#process#networking#lsof

Command

lsof -i :3000 -t | xargs kill -9


Short Description

Quickly identifies which PID (Process Identifier) is actively bound to a port (e.g. 3000, 8080) and terminates it immediately with SIGKILL (-9).


Breakdown

# Step 1: List only the PID (-t) listening on port 3000
lsof -i :3000 -t

# Step 2: Pipe the PID into kill (graceful SIGTERM first)
lsof -i :3000 -t | xargs kill

# Or if process is completely unresponsive, force kill:
lsof -i :3000 -t | xargs kill -9

Alternatives by Tool

Using fuser (Standard Linux)

sudo fuser -k 3000/tcp

Using ss and pkill

ss -lptn 'sport = :3000'

On this page