kill-port

A tiny utility to instantly kill process running on a specific port. Because EADDRINUSE is the enemy.

bash
#!/bin/bash
# save as 'kp' in your path

if [ -z "$1" ]; then
  echo "Usage: kp <port>"
  exit 1
fi

lsof -ti:$1 | xargs kill -9
echo "Killed port $1"

Use it:

npx kill-port 3000

It does one thing. It's boring. It works.