xxxxxxxxxx
sudo lsof -t -i tcp:80 -s tcp:listen | sudo xargs kill
xxxxxxxxxx
Steps to kill process running on port 8080 in Windows cmd/terminal,
#1 netstat -ano | findstr < Port Number >
#2 taskkill /F /PID < Process Id >
xxxxxxxxxx
# 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)
# (-9 corresponds to the SIGKILL - terminate immediately/hard kill signal: see List of Kill Signals and What is the purpose of the -9 option in the kill command?. If no signal is specified to kill, the TERM signal a.k.a. -15 or soft kill is sent, which sometimes isn't enough to kill a process.).
xxxxxxxxxx
# Find the PID of the process using port 8080
lsof -t -i :8080
# Kill the process using the PID obtained from the previous command
kill <PID>
xxxxxxxxxx
#list process running on specified port (here 5000, change to your port)
sudo lsof -i:5000
#kill process on specified port (here 5000, change to your port)
kill -9 $(sudo lsof -t -i:5000)