Amazing!神秘程序占用tensorbroad端口6006

Amazing啊!好奇怪的端口占用问题但是找不到占用的进程…

和这个帖子似乎类似:

我在 win11 的 WSL2 下试图开启 tensorbroad:

tensorboard --logdir runs/
/home/xxxx/projects/.venv/lib/python3.11/site-packages/tensorboard/default.py:30: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources
TensorFlow installation not found - running with reduced feature set.

NOTE: Using experimental fast data loading logic. To disable, pass
    "--load_fast=false" and report issues on GitHub. More details:
    https://github.com/tensorflow/tensorboard/issues/4784

Address already in use
Port 6006 is in use by another program. Either identify and stop that program, or start the server with a different port.

然而却无法排查到占用进程:

lsof -i:6006
<无任何输出>

曾经我重启过电脑之后好了 :innocent:但还是想知道此事如何发生。

BTW,不知为何,更换端口不一定有用:

tensorboard --logdir runs/ --port=6007
/home/xxxx/projects/.venv/lib/python3.11/site-packages/tensorboard/default.py:30: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources
TensorFlow installation not found - running with reduced feature set.

NOTE: Using experimental fast data loading logic. To disable, pass
    "--load_fast=false" and report issues on GitHub. More details:
    https://github.com/tensorflow/tensorboard/issues/4784

Address already in use
Port 6007 is in use by another program. Either identify and stop that program, or start the server with a different port.

windows默认保留一些随机端口,是一组区间范围。具体可查阅https://zhuanlan.zhihu.com/p/474392069 状态就是 没有任何程序占用,但是无法申请使用端口。提示的消息是默认消息,不代表有进程使用。

但是按道理 tensorbroad 默认使用的 6006 端口应该不在此列…

由于我赶时间,已经暂时通过重启解决。我下次遇到再试试 :innocent: :innocent:

感谢佬友

win本身会占用一些端口的,wsl里面不一定能找到。我就是一开始华硕奥创占了9000还是啥端口,怎么都关不掉

请问这个有办法在物理机上看/查询的到吗?

直接在win终端里面:

netstat -ano | findstr :6006

再查询.exe

tasklist | findstr 显示的PID

先看一下这几个端口在win里面是不是实际被其他程序占用了

如果win没有应用程序占用端口的,你可以问问AI:


遗憾的是,我在win下这个命令抓取不到任何 6006 端口的任务 :innocent:

忽然发现我没注意看AI给的回答里的排查命令 :innocent:

有用的命令是 netsh int ipv4 show excludedportrange protocol=tcp ,原本端口就是保留的,没有任何进程使用自然查询不到

我现在不能复现端口被占用的问题,我的输出结果为:

netsh int ipv4 show excludedportrange protocol=tcp

Protocol tcp Port Exclusion Ranges

Start Port    End Port
----------    --------
        80          80
     50000       50059     *

* - Administered port exclusions.

那就不用管这种事情,我认为应该是你自己开启了一个端口没有进行释放,代码写错了或者其他问题。 board如果端口被使用会自动+1,问题+1以后的端口也被使用,这个必然和之前有关。
不太确定是否和
https://blog.csdn.net/yog99/article/details/151281386 相关,需要做故障分析排查

那就不用管这种事情,我认为应该是你自己开启了一个端口没有进行释放,代码写错了或者其他问题。 board如果端口被使用会自动+1,问题+1以后的端口也被使用,这个必然和之前有关。

好的,感谢解答hhh。 我早上提问时是刚刚开的电脑和新开的WSL :innocent: 如果连重启后都会保留之前的端口占用的话那也很奇怪 :innocent: