← Back to Labs / Open WebUI

Fix: Open WebUI Connection Refused (Ollama Not Found)

OpsNexusAI Engineering
4 min read

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-webui shows ConnectionError: HTTPConnectionPool(host='localhost', port=11434).

Root Causes

  1. Wrong Hostname: Inside a Docker network, containers cannot reach each other via localhost. They must use the service name.
  2. Missing Network Bridge: The two containers are on different Docker networks and cannot route to each other.
  3. Ollama Not Listening: Ollama is configured to only listen on 127.0.0.1 inside 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

  1. Open the browser console (F12) on the WebUI.
  2. Check if requests to /api/models return a 200 OK.
  3. Inside the WebUI container, try to ping the Ollama container: docker exec -it open-webui ping ollama

Prevention

  • Container Naming: Always use explicit container_name fields 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.

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 Publication

OpsNexusAI 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.