Skip to content

Instantly share code, notes, and snippets.

@yzhong52

yzhong52/readme.md

Created Oct 30, 2020
Embed
What would you like to do?
To Kill a Process Using a Port (Mac)

Put this helper funciton in your ~/.zshrc or ~/.bash_profile:

release_port() {
    pid=$(lsof -ti:$1)
    if [ -z $pid ]; then
        echo "Nothing is running on port $1"
    else
        kill $pid
        echo "Killed process on port $1 with pid $pid"
    fi
}

Use it like

release_port 3030
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment