AnythingLLM 容器仍然无法访问宿主机上的 LM Studio 的端口(1234)
并保存,模型就可以连上了。需要我帮你检查 AnythingLLM 的配置界面截图,或指导你通过命令行拉通测试也可以。要吗?
base) powersys@sam:~$ 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 130086 ms: Connection timed out (base) powersys@sam:~$ 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 130694 ms: Connection timed out
你遇到的这个持续超时问题说明:
🔴 AnythingLLM 容器仍然无法访问宿主机上的 LM Studio 的端口(1234)
✅ 问题确认
你当前:
-
LM Studio 是通过图形界面运行的 AppImage
-
默认监听
127.0.0.1:1234—— 只能本地访问(容器访问不到)
✅ 解决方案
🔧 方法一:用 host.docker.internal 连接宿主机(推荐)
在
AnythingLLM中填写的模型地址 不要用172.17.0.1,而是用:
http://host.docker.internal:1234
然后在宿主机上运行如下命令来验证:
curl http://host.docker.internal:1234/v1
如果你用的是 Linux,它默认没有 host.docker.internal,需要添加:
sudo iptables -t nat -A OUTPUT -d host.docker.internal -j DNAT --to-destination 172.17.0.1
或者更简单方式是编辑 /etc/hosts:
echo "172.17.0.1 host.docker.internal" | sudo tee -a /etc/hosts
🧪 验证连通性(从容器内)
docker exec -it anythingllm curl http://host.docker.internal:1234/v1
如果你看到这个响应:
{"error":"Unexpected endpoint or method.(GET /v1)"}
说明通了 ✅
🚫 方法二:不用 AppImage GUI,改用 CLI 启动 LM Studio
如果你愿意放弃 GUI,可以试试官方开源的 LM Studio API 兼容后端(如 llama-cpp-server 或 Ollama)。
✅ 最后,在 AnythingLLM 设置中填入:
http://host.docker.internal:1234
并保存,模型就可以连上了。
需要我帮你检查 AnythingLLM 的配置界面截图,或指导你通过命令行拉通测试也可以。要吗?
更多推荐

所有评论(0)