Skip to content

Instantly share code, notes, and snippets.

@ukor
Created July 7, 2023 11:59
Show Gist options
  • Select an option

  • Save ukor/7812f973cd34d20e8d019d0ecbbac35b to your computer and use it in GitHub Desktop.

Select an option

Save ukor/7812f973cd34d20e8d019d0ecbbac35b to your computer and use it in GitHub Desktop.
Shell Scripting
[See Stackoverflow Question](https://stackoverflow.com/questions/3855127/find-and-kill-process-locking-port-3000-on-mac)
Add this to your profile
```sh
findAndKillPort() {
port=$(lsof -n -i4TCP:$1 | grep LISTEN | awk '{ print $2 }') kill -9 $port
}
```
- Add alias
```sh
alias killport=findAndKillPort
```
- Usage
```sh
killport 5000
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment