mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[GH-ISSUE #21225] issue: Ollama API connection attempts when ENABLE_OLLAMA_API is False (url_idx endpoints) #34946
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tosfos on GitHub (Feb 6, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/21225
Bug Description
When
ENABLE_OLLAMA_APIis set toFalse, Open WebUI still attempts to connect to Ollama API endpoints when accessing routes that include aurl_idxparameter, causing connection errors even though Ollama APIs are explicitly disabled.Error Log
Root Cause
The issue occurs in endpoints that accept an optional
url_idxparameter. Whenurl_idxisNone, these endpoints correctly callget_all_models()which checksENABLE_OLLAMA_APIbefore making requests. However, whenurl_idxis provided, the code directly accessesOLLAMA_BASE_URLS[url_idx]and makes HTTP requests without first checking theENABLE_OLLAMA_APIflag.Affected Endpoints
GET /ollama/api/tags/{url_idx}(line 440-490 inbackend/open_webui/routers/ollama.py)url_idxis provided, it directly accessesOLLAMA_BASE_URLS[url_idx]at line 450 without checkingENABLE_OLLAMA_APIurl_idx is Nonedoes it callget_all_models()which properly checks the flagGET /openai/models/{url_idx}(line 543+ inbackend/open_webui/routers/openai.py)url_idxis provided, it accessesOPENAI_API_BASE_URLS[url_idx]without checkingENABLE_OPENAI_APICode Evidence
Buggy code in
get_ollama_tags(lines 447-450):Correct implementation in
get_ollama_versions(line 558):Steps to Reproduce
ENABLE_OLLAMA_API=Falsein environment variables/ollama/api/tags/{url_idx}with any validurl_idx(e.g.,0)Expected Behavior
When
ENABLE_OLLAMA_APIisFalse, all Ollama API endpoints should return an appropriate error (e.g., 503 Service Unavailable or 403 Forbidden) without attempting to connect to Ollama servers, regardless of whetherurl_idxis provided or not.Actual Behavior
When
ENABLE_OLLAMA_APIisFalseandurl_idxis provided:OLLAMA_BASE_URLS[url_idx]Proposed Fix
Add
ENABLE_OLLAMA_API/ENABLE_OPENAI_APIchecks at the beginning of affected endpoint functions, before accessingurl_idx-specific URLs. For example:Impact
Environment
ENABLE_OLLAMA_API=Falsehost.docker.internal:11434as default Ollama URL@Classic298 commented on GitHub (Feb 6, 2026):
https://github.com/open-webui/open-webui/pull/21226