Last active
October 18, 2019 07:36
-
-
Save ERPedersen/21b3e3e9f9efc8dc0eb2150547cbc23a to your computer and use it in GitHub Desktop.
Free blocked port
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Frees up the provided port by killing whatever process is blocking it. | |
# | |
# Example: | |
# freeport 8080 | |
function freeport () { | |
local result=$(lsof -i :$1 | grep node | awk '{print $2}') | |
if [[ ! -z $result ]]; then | |
kill $result | |
echo "Process $result successfully killed" | |
echo "Port $1 is now free" | |
else | |
echo "Port $1 is already free" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment