Mintplex-Labs/anything-llm · critical · Error

No Ollama Base Path was set.

Error message

No Ollama Base Path was set.

What it means

Synchronous constructor guard. OllamaAILLM cannot be instantiated unless OLLAMA_BASE_PATH is set; the value is required to build the underlying Ollama client (host) used for every subsequent call. Thrown at 'new OllamaAILLM(...)' before any network activity.

Source

Thrown at server/utils/AiProviders/ollama/index.js:20

  writeResponseChunk,
  clientAbortedHandler,
  formatChatHistory,
} = require("../../helpers/chat/responses");
const { NativeEmbedder } = require("../../EmbeddingEngines/native");
const {
  LLMPerformanceMonitor,
} = require("../../helpers/chat/LLMPerformanceMonitor");
const { Ollama } = require("ollama");
const { v4: uuidv4 } = require("uuid");

// Docs: https://github.com/jmorganca/ollama/blob/main/docs/api.md
class OllamaAILLM {
  /** @see OllamaAILLM.cacheContextWindows */
  static modelContextWindows = {};

  constructor(embedder = null, modelPreference = null) {
    if (!process.env.OLLAMA_BASE_PATH)
      throw new Error("No Ollama Base Path was set.");

    this.className = "OllamaAILLM";
    this.authToken = process.env.OLLAMA_AUTH_TOKEN;
    this.basePath = process.env.OLLAMA_BASE_PATH;
    this.model = modelPreference || process.env.OLLAMA_MODEL_PREF;
    this.keepAlive = process.env.OLLAMA_KEEP_ALIVE_TIMEOUT
      ? Number(process.env.OLLAMA_KEEP_ALIVE_TIMEOUT)
      : 300; // Default 5-minute timeout for Ollama model loading.

    const headers = this.authToken
      ? { Authorization: `Bearer ${this.authToken}` }
      : {};
    this.client = new Ollama({
      host: this.basePath,
      headers: headers,
      fetch: OllamaAILLM.applyOllamaFetch(),
    });
    this.embedder = embedder ?? new NativeEmbedder();

View on GitHub (pinned to 526360e320)

Solutions

  1. Set OLLAMA_BASE_PATH to the Ollama API origin (e.g. http://127.0.0.1:11434) in .env.
  2. Restart the AnythingLLM server so the new env is picked up.
  3. Confirm via the UI: Settings > LLM Provider > Ollama shows a non-empty base path.
  4. If using Docker, verify the env var is passed to the container and the Ollama address is reachable from inside it.

Example fix

# before
# (OLLAMA_BASE_PATH unset)

# after - .env
OLLAMA_BASE_PATH=http://127.0.0.1:11434
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.OLLAMA_BASE_PATH || !process.env.OLLAMA_BASE_PATH.trim())
  throw new Error('OLLAMA_BASE_PATH must be set before starting OllamaAILLM.');

Prevention

When it happens

Trigger: Instantiating OllamaAILLM (typically by the provider factory during a chat request or at boot) when process.env.OLLAMA_BASE_PATH is undefined or empty string.

Common situations: .env file missing or not loaded; var typo'd as OLLAMA_HOST or OLLAMA_BASE_URL; fresh deployment where the Ollama provider was selected in the UI but the env was never written; docker-compose without the var passed through.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/c8bd50ff2ed9693e. Report an issue: GitHub.