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:

lsof -i:18080

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

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:

kill -9 19802

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

Author: Yakima
关于作者:楠溪江人,出生于1991年,目前坐标上海。读书时代跳过级、保过送,工作后转过行。2013年本科毕业于北药。看书、码字、敲代码、打羽毛球是我花时间的爱好。曾在某上市药企任国际药品注册岗,现在某高新企业任前端管理岗。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据