Sometimes you want to kill whatever is running on a specific port.
One way to do this is to first use netstat -tpln
or ss -l
to identify the PID of
the process running on the given port.
Then note the PID and then kill it using kill $PID
.
fuser
lets you do this in a single command:
To kill processes with TCP port 8080 open, IPv4 and IPv6
fuser -k 8080/tcp
To kill processes with TCP port 8080 open only on IPv6:
fuser -k -6 8080/tcp
To kill processes with UDP port 5300 open
fuser -k 8080/udp