Skip to content

Instantly share code, notes, and snippets.

@adrianolsk
Created January 7, 2018 13:19
Show Gist options
  • Save adrianolsk/c4671e497b20b9c1c111035672f9a65b to your computer and use it in GitHub Desktop.
Save adrianolsk/c4671e497b20b9c1c111035672f9a65b to your computer and use it in GitHub Desktop.
Kill a process by port
#This will print you PID of process bound on that port.
fuser 8080/tcp
#And this will kill that process.
fuser -k 8080/tcp
#Works on Linux only. More universal is use of lsof -i4 (or 6 for IPv6).
#To list any process listening to the port 8080:
lsof -i:8080
#To kill any process listening to the port 8080:
kill $(lsof -t -i:8080)
#or more violently:
kill -9 $(lsof -t -i:8080)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment