(base) powersys@sam:~/work/anything-llm/anything-llm/LMStudio$ docker exec -it anythingllm curl http://172.17.0.1:1234/v1 curl: (28) Failed to connect to 172.17.0.1 port 1234 after 130837 ms: Connection timed out

这个错误说明:AnythingLLM 容器无法访问你宿主机的 LM Studio 服务172.17.0.1:1234 端口请求超时),也就解释了你在网页里输入 hello 之后三个点一直跳动的原因 —— 它连不上本地的大模型。


✅ 目标

AnythingLLM 能访问到你宿主机上运行的 LM Studio(监听在 localhost:1234)。


🔍 原因分析

LM Studio 默认监听在 127.0.0.1:1234,只能被宿主机本机访问,Docker 容器访问不了 127.0.0.1 的端口


✅ 解决方法(推荐)

🛠 修改 LM Studio 启动参数,让它监听 0.0.0.0:1234

你运行 LM-Studio-0.3.18-3-x64.AppImage 时,在启动参数中加入:

./LM-Studio-0.3.18-3-x64.AppImage --server --port 1234 --host 0.0.0.0

这让 LM Studio 监听在 0.0.0.0:1234,也就是允许外部(Docker 容器)访问。

如果是图形界面启动,你需要检查是否有「设置监听地址(host)」的配置项,没有的话建议切换为命令行启动,或使用 LM Studio 提供的 API Server 功能。


📍 然后重试:

docker exec -it anythingllm curl http://172.17.0.1:1234/v1

如果出现:

{"error":"Unexpected endpoint or method.(GET /v1)"}

就说明网络通了 ✅


💡 最后一步:在 AnythingLLM 中绑定模型

  1. 打开浏览器访问:http://localhost:3001/onboarding 或后台设置界面

  2. 填入模型 API 地址为:

http://172.17.0.1:1234
  1. 模型类型选择:OpenAI Compatible(或自定义)

  2. 点击 Save & Test 连接


确认一下你是否是通过 GUI 启动 LM Studio,如果不方便用参数启动,也可以考虑用 host 网络模式 启动 docker(我也可以教你)。

 

Logo

免费领 200 小时云算力,进群参与显卡、AI PC 幸运抽奖

更多推荐