Kill process running on port

a small dive into unix commands

Kevin McCarthy
2 min readSep 27, 2019

TL:DR Below command will kill what’s on port 3000

kill $(lsof -ti:3000)

I’ve written before about finding the process running on a port and then manually killing it. Taking two steps for this was pretty annoying so I went and found how to do it in one.

Let’s break down whats happening here.

lsof is the command to list open files (ls open files)

-i Lists IP sockets

-i:3000 returns only open files running on port 3000

-t (terse) this returns just the Process Id or PID

So lsof -ti:3000 PIDs currently running on port 3000

kill $(…) pass the kill command whatever is in the brackets.

kill $(lsof -ti:3000) kill all the processes running on port 3000

--

--

No responses yet