Skip to content

Find Program using Specific Port and Closed It

Assume that you now want to use port 18080 to run your new program, but you find that the port is already employed by other program. What need you do? First, find the target program using the specific port (18080, in this case), then shut the program down to free the specific port. To find the target program using the port 18080:

default
lsof -i:18080

And then you will get information looking like the below one:

default
COMMAND PID    USER     FD   TYPE  DEVICE   SIZE/OFF  NODE  NAME
node    19802  orzzone  llu  IPv6  7394347       0t0  TCP   *:18080(LISTEN)

See the PID (19802, in the above example)? It's what you need in the next step. Now kill the process:

default
kill -9 19802

All is done. Now the port 18080 is free for further use again.

天上的神明与星辰,人间的艺术和真纯,我们所敬畏和热爱的,莫过于此。