OpenWebUI连接不上Ollama模型,Ubuntu24.04

Source

这里写自定义目录标题

问题介绍

  • 操作系统 Ubuntu24.04
  • Ollama 使用默认安装方法(官网https://github.com/ollama/ollama) curl -fsSL https://ollama.com/install.sh | sh 安装在本机
  • OpenWebUI
    使用默认docker安装方法(官网教程安装https://docs.openwebui.com/) docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main 安装在docker

  • 使用 http://127.0.0.1:11434/ 访问Ollama显示Ollama is running,说明Ollama正常。

  • Ollama中安装了模型,并且可以命令行形式使用。

  • 使用http://localhost:8080/登录OpenWebUI后发现没有模型

解决方法

  1. 在OpenWebUI管理面板中,管理Ollama API连接 默认为http://host.docker.internal:11434/,这是windows中的方式,需要改为http://127.0.0.1:11434
  2. 在 访问 Ollama 时遇到问题? 点击这里获取帮助。点击导航到https://github.com/open-webui/open-webui#troubleshooting,根据教程Open WebUI: Server Connection Error
    If you’re experiencing connection issues, it’s often due to the WebUI docker container not being able to reach the Ollama server at 127.0.0.1:11434 (host.docker.internal:11434) inside the container . Use the --network=host flag in your docker command to resolve this. Note that the port changes from 3000 to 8080, resulting in the link: http://localhost:8080.
docker run -d --network=host -v open-webui:/app/backend/data -e OLLAMA_BASE_URL=http://127.0.0.1:11434 --name open-webui --restart always ghcr.io/open-webui/open-webui:main

删除docker,并使用上面的命令重新创建docker,使用http://localhost:8080访问OpenWebUI即可。