loader spinner

How to kill process in mac

December 01, 2019 3:36pm - 1 min read

Last updated on: December 13, 2019 6:56am

As you have localhost:8000 running in your browser while you developing something, you may need to end that process and run another port. So it keeps running localhost:8001, localhost:8002, localhost:8003 and so on…

This is quite handy if you know the following commands:

To check whether a specific port for example 8000 has something running, you can type the following command in your mac terminal:

lsof -i :8000

It will show something like this:

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 53410 sajib 50u IPv4 0x588926be8afb314f 0t0 TCP localhost:vcom-tunnel (LISTEN)
node 53410 sajib 58u IPv4 0x588926be8afb8667 0t0 TCP localhost:vcom-tunnel->localhost:53932 (CLOSED)
node 53410 sajib 59u IPv4 0x588926be8aab4d6f 0t0 TCP localhost:vcom-tunnel->localhost:53934 (CLOSE_WAIT)

It shows that port 8000 is busy. While 8000 is occupied with something, you can’t run anything there. So we need to clear this port so that we can run another program. You need take a note the PID value, in this case, is 53410.

So to clear or kill this process, you need to type the following:

kill -9 53410

And now the port 8000 is clear. Now you can run the program again in this port.

Hope this information may help someone.

Last updated on: December 13, 2019 6:56am