ComfyUI-Roundabout 报错 WinError 10048 端口 8189 被占用排错实录

2次阅读
没有评论

现象:ComfyUI GUI 可以正常打开访问,但控制台抛出 [Errno 10048] 通常每个套接字地址(协议/网络地址/端口)只允许使用一次,来自 ComfyUI‑Roundabout 的 mcp_server.py,MCP 智能体功能失效。

完整错误日志片段

ERROR:    [Errno 10048] error while attempting to bind on address ('127.0.0.1', 8189): [winerror 10048] 通常每个套接字地址(协议/网络地址/端口)只允许使用一次。
[INFO] To see the GUI go to: http://192.168.31.197:10004
[INFO] StreamableHTTP session manager shutting down
[WARNING] Cannot connect to comfyregistry.
FETCH DATA from: C:\Work\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\user\__manager\cache\1514988643_custom-node-list.json [DONE]
[INFO] [ComfyUI-Manager] All startup tasks have been completed.
[ERROR] Task exception was never retrieved
future: <Task finished name='Task-27' coro=<serve_embedded() done, defined at C:\Work\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Roundabout\mcp_server.py:574> exception=SystemExit(3)>
Traceback (most recent call last):
  File "C:\Work\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\python_embeded\Lib\site-packages\uvicorn\server.py", line 173, in startup
    server = await loop.create_server(
             ^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<5 lines>...
    )
    ^
  File "asyncio\base_events.py", line 1630, in create_server
OSError: [Errno 10048] error while attempting to bind on address ('127.0.0.1', 8189): [winerror 10048] 通常每个套接字地址(协议/网络地址/端口)只允许使用一次。

During handling of the above exception, another exception occurred:
……
SystemExit: 3

问题根因

  1. ComfyUI 主服务运行在 10004 端口,本身不受该错误影响,网页可以正常打开
  2. 报错来源:ComfyUI‑Roundabout 插件内置 MCP 服务,硬编码默认绑定 127.0.0.1:8189
  3. WinError 10048 = 端口已被占用。绝大多数场景是上一次关闭 ComfyUI 没有完全退出,uvicorn 后台残留进程继续持有 8189 端口;也可能是多开 ComfyUI、其他本地 AI/MCP 工具占用该端口。
  4. 附带的 Cannot connect to comfyregistry. 是 ComfyUI‑Manager 网络连接警告,和端口报错无关,不影响运行
  5. Task exception was never retrieved 是异步任务未捕获异常,根源就是 8189 端口绑定失败。

解决方案(4 种,按优先级)

方案一:杀死占用 8189 端口残留进程(快速临时修复)

打开 Windows CMD,执行下面命令查询占用端口的 PID:

netstat -ano | findstr :8189

输出结果最后一列数字即为进程 PID。

使用 PID 强制杀掉进程,将下面 1234 替换为你查到的 PID 号:

taskkill /F /PID 1234

执行完成后,重启 ComfyUI 即可。

高频场景:直接点窗口叉号关闭 ComfyUI,uvicorn 子进程不会跟着退出,端口持续被占用,下次启动直接报 10048。

一键处理 bat 脚本

新建文本,复制下面内容,保存为 kill_8189.bat,编码 ANSI,以后双击即可释放 8189 端口。

@echo off
echo 正在查找8189端口占用进程...
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":8189"') do (
    echo 发现PID: %%a
    taskkill /F /PID %%a
)
echo 端口处理完成,按任意键退出
pause

方案二:修改 Roundabout 插件更换 MCP 端口【根治方案,推荐】

  1. 打开文件: ComfyUI/custom_nodes/ComfyUI‑Roundabout/mcp_server.py
  2. 定位大约 574 行 serve_embedded 函数内 uvicorn 启动代码,找到端口配置。 原代码类似:
uvicorn.run(app, host="127.0.0.1", port=8189)
  1. 修改端口,更换为空闲端口,示例改为 8190:
uvicorn.run(app, host="127.0.0.1", port=8190)
  1. 保存文件,重启 ComfyUI。

修改后注意:后续调用 Roundabout MCP 客户端时,需要同步填写新端口号。

方案三:临时禁用 Roundabout 插件

如果暂时不用 Roundabout MCP 功能,直接重命名插件目录: ComfyUI/custom_nodes/ComfyUI‑Roundabout 改为 ComfyUI/custom_nodes/_ComfyUI‑Roundabout

重启 ComfyUI,该报错完全消失,代价是 Roundabout 全部功能不可用。

方案四:排查外部软件占用

8189 端口也可能被以下程序占用:

  • 同时开启多个 ComfyUI 实例
  • 其他本地 MCP 服务、大模型后端、AI 工具服务

检查系统托盘、任务管理器,关闭对应程序,再启动 ComfyUI。

排错小结

  1. 看到 10048 先分清:ComfyUI 主 GUI 没死,只是 Roundabout MCP 子服务启动失败。
  2. 优先用 bat 脚本清理残留进程;反复复现就直接改插件端口号。
  3. 不要被无关日志干扰:comfyregistry连接失败属于网络问题,和端口冲突无关。

适用环境:Windows 便携版 ComfyUI + ComfyUI‑Roundabout 插件,常见于本地 AI 智能体 MCP 调试场景。

正文完
可以使用微信扫码关注公众号(ID:xzluomor)
post-qrcode
 0
评论(没有评论)
验证码