Find Which Process is Listening on a Port
Sometimes I need to find out which process is listening on a specific port, usually so I can kill it.
On macOS:
sudo lsof -i -P | grep LISTEN | grep :$PORT
And on Linux:
netstat -pntl | grep $PORT
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
Sometimes I need to find out which process is listening on a specific port, usually so I can kill it.
On macOS:
sudo lsof -i -P | grep LISTEN | grep :$PORT
And on Linux:
netstat -pntl | grep $PORT