A MacOS terminal command to kill the process running on a given TCP port.
kill-port <PORT_NUMBER>- Create a local file called "kill-port"
touch ~/kill-port-
Copy and paste the script from kill-port.sh into the newly created file.
-
Make the file executable
chmod +x ~/kill-port- Copy the file to /usr/local/bin
mkdir ~/bin
mv ~/kill-port ~/bin/Then add the following to your ~/.zshrc or ~/.bashrc file:
export PATH=$PATH:~/binAnd save and reload your configuration with:
source ~/.zshrc or source ~/.bashrc
sudo mv ~/kill-port /usr/local/bin/