Created
January 7, 2018 13:19
-
-
Save adrianolsk/c4671e497b20b9c1c111035672f9a65b to your computer and use it in GitHub Desktop.
Kill a process by port
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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