Kill the running application using the port number
Apr 21, 2024/
#bash
/-1 minWhen I close my applications running in the terminal, sometimes ports don't die and
killall node
doesn't work.
You can use
kill
to force close the port.
1sudo kill $(sudo lsof -t -i:{PORT})
You can then assign aliases to simplify usage.
1alias killport="killport_function”
2killport_function ()
3{
4 sudo kill $(sudo lsof -t -i:$1)
5}
Put the above code in your
~/.zshrc
file and run source ~/.zshrc
. You can now use it as follows.
1killport 3000