#!/bin/bash
echo Enter port number to kill
read port_number
pid="$(lsof -i:$port_number | awk '{ print $2 }' | sed -n 2p)"
kill -9 $pid
echo $?
How to run it? ./killProcessOnPort.sh Terminal will ask you the port number to kill. and we are good to go...
Please share and give feedback.