Find and kill a process

Find and kill a process

Find and kill a process.

List all processes listening on a specific port

sudo lsof -i -P | grep LISTEN

The output will look something like this:

rapportd    123            ash    5u  IPv4 0x84512a8572c9xxxx      0t0    TCP *:62003 (LISTEN)
rapportd    123            ash    6u  IPv6 0x84512a857627xxxx      0t0    TCP *:62003 (LISTEN)
mongod      414            ash    9u  IPv4 0x84512a857926xxxx      0t0    TCP localhost:27017 (LISTEN)
Loom       3315            ash   28u  IPv4 0x84512a85785cxxxx      0t0    TCP localhost:11223 (LISTEN)
node      38238            ash   22u  IPv6 0x84512a857627xxxx      0t0    TCP *:5000 (LISTEN)
node      68336            ash   22u  IPv6 0x84512a858bb4xxxx      0t0    TCP *:443 (LISTEN)

Now you can kill the process by using the PID:

sudo kill -9 68336

© 2023. All rights reserved.