Skip to content

Instantly share code, notes, and snippets.

@marciopuga
Created October 26, 2021 10:50
Show Gist options
  • Save marciopuga/fb304f57068f98e16df566f283518825 to your computer and use it in GitHub Desktop.
Save marciopuga/fb304f57068f98e16df566f283518825 to your computer and use it in GitHub Desktop.
Kill service/server running on a port

Kill any server running on port 8080

lsof -i TCP:8080 | awk 'NR > 1 {print $2}' | xargs kill -9

or add to bash

function killport() {
  echo "Killing processes on port $1"
  lsof -i TCP:$1 | awk 'NR > 1 {print $2}'  | xargs kill -9
}

and use as $ killport 8080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment