Copied from: stackoverflow
Our example port is 3000. Replace it with the port number you need.
# On linux
netstat -vanp tcp | grep 3000
# On Centos
netstat -vanp --tcp | grep 3000
# On OSX El Capitan+ (or if your netstat doesn't support -p)
sudo lsof -i tcp:3000
Our example process id (PID) is 35642. Replace it with the process id you find from the previous command.
sudo killall 35642