Last active
April 6, 2022 15:59
-
-
Save martin-cotta/f8335efa8a398cf8e12fc91b63dc610b to your computer and use it in GitHub Desktop.
Kill process on specific port
This file contains 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
# sudo lsof -i :<PortNumber> | |
# kill -9 <PID> | |
# or | |
# kill -9 $(lsof -ti:<Port>, <Port>) | |
# The -t flag removes everything but the PID from the lsof output | |
# Error: listen EADDRINUSE: address already in use ::::3000 | |
$ lsof -i tcp:3000 | |
# COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME | |
# node 44475 chen5 31u IPv4 0x8b1721168764e4bf 0t0 TCP *:strexec-s (LISTEN) | |
$ kill -9 44475 | |
# or | |
$ kill -9 $(lsof -ti:3000) | |
#or | |
npx kill-port 3000 | |
# or | |
$ lsof -ti:3000 | xargs kill |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment