Fix: Open WebUI Connection Refused (Ollama Not Found)
Fix: Open WebUI Connection Refused (Ollama Not Found)
After deploying the stack, the Open WebUI interface loads but shows “Ollama Not Found” or fails to list any models.
Quick Fix
Update your OLLAMA_BASE_URL in the docker-compose.yml to use the container name rather than localhost:
environment:
- OLLAMA_BASE_URL=http://ollama:11434
Symptoms
- UI Error: A red notification in Open WebUI stating “Connection Refused” or “Ollama Error.”
- Empty Model List: The model selector dropdown is empty despite models being pulled.
- Log Messages:
docker logs open-webuishowsConnectionError: HTTPConnectionPool(host='localhost', port=11434).
Root Causes
- Wrong Hostname: Inside a Docker network, containers cannot reach each other via
localhost. They must use the service name. - Missing Network Bridge: The two containers are on different Docker networks and cannot route to each other.
- Ollama Not Listening: Ollama is configured to only listen on
127.0.0.1inside its container, blocking external requests from the WebUI.
Step-by-Step Fix
1. Correct the Base URL
In your docker-compose.yml, locate the open-webui service and ensure the environment variable points to the service name of the Ollama container:
open-webui:
environment:
- OLLAMA_BASE_URL=http://ollama:11434
(Assuming your Ollama service is named ollama).
2. Force Ollama to Listen on All Interfaces
Ollama needs to accept connections from the Docker bridge. Ensure the Ollama service has this environment variable:
ollama:
environment:
- OLLAMA_HOST=0.0.0.0
3. Verify Common Network
Ensure both services are on the same network:
services:
ollama:
networks: [ai_network]
open-webui:
networks: [ai_network]
networks:
ai_network:
driver: bridge
Verification
- Open the browser console (F12) on the WebUI.
- Check if requests to
/api/modelsreturn a200 OK. - Inside the WebUI container, try to ping the Ollama container:
docker exec -it open-webui ping ollama
Prevention
- Container Naming: Always use explicit
container_namefields in Compose to avoid automatic suffixing (e.g.,ollama_1). - Health Checks: Add a health check to the Ollama service so that Open WebUI only starts once the backend is ready.
Related Guides
- Tutorial: Deploying Ollama with Docker Compose.
- Blueprint: Private AI Stack Blueprint.
FAQ
Q: Can I use an IP address instead of a hostname? A: Yes, but it is not recommended as Docker container IPs can change on restart. Service names are persistent.
OpsNexusAI Engineering
Verified Lab PublicationOpsNexusAI is a technical laboratory dedicated to sovereign AI infrastructure. Every implementation guide and architectural blueprint published here is tested on physical hardware and isolated networks. Our team specializes in the deployment of private LLMs, network hardening with OPNsense, and enterprise-grade automation patterns.
Join the OpsNexus Brief
Get technical teardowns on sovereign AI architectures delivered to your inbox.