Find and kill processes at a given port

Duration
1 minute read
Last Updated
Oct 2021
Topics
  • code snippet
  • shell scripting

In your terminal or .zshrc, etc:

function killport {
    echo '🚨 Killing all processes at port' $1
    lsof -ti tcp:$1 | xargs kill
}

Usage

killport 8080

# 🚨 Killing all processes at port 8080
Hire me — I'm seeking my next full-time role.