如何找出进程正在使用哪个端口号以及进程使用特定端口号

How to find out which port number a process is using and the process using a specific port number

我是 openhab 的新手,在启动服务器后 /etc/init.d/openhab2 start 我明白了 [ ok ] Starting openhab2 (via systemctl): openhab2.service,但我仍然无法通过 http://localhost:8080/ 访问该平台 我想知道:

which process is using port 8080

which port openhab runs on

谢谢

你可以使用lsof,

lsof | grep TCP | grep 8080lsof | grep openhab | grep TCP

如果进程分叉并且子进程是正在使用端口的进程,则它可能无法按预期工作