Mintplex-Labs/anything-llm · error · Error
Ollama service could not be reached. Is Ollama running?
Error message
Ollama service could not be reached. Is Ollama running?
What it means
Thrown at the start of embedChunks (line 80) when #isAlive() returns false. #isAlive does a plain fetch to this.basePath and treats any non-ok response or thrown error as dead. This preflight prevents queuing many batched embed calls against an unreachable daemon.
Source
Thrown at server/utils/EmbeddingEngines/ollama/index.js:81
}
/**
* This function takes an array of text chunks and embeds them using the Ollama API.
* Chunks are processed in batches based on the maxConcurrentChunks setting to balance
* resource usage on the Ollama endpoint.
*
* We will use the num_ctx option to set the maximum context window to the max chunk length defined by the user in the settings
* so that the maximum context window is used and content is not truncated.
*
* We also assume the default keep alive option. This could cause issues with models being unloaded and reloaded
* on low memory machines, but that is simply a user-end issue we cannot control. If the LLM and embedder are
* constantly being loaded and unloaded, the user should use another LLM or Embedder to avoid this issue.
* @param {string[]} textChunks - An array of text chunks to embed.
* @returns {Promise<Array<number[]>>} - A promise that resolves to an array of embeddings.
*/
async embedChunks(textChunks = []) {
if (!(await this.#isAlive()))
throw new Error(
`Ollama service could not be reached. Is Ollama running?`
);
this.log(
`Embedding ${textChunks.length} chunks of text with ${this.model} in batches of ${this.maxConcurrentChunks}.`
);
let data = [];
let error = null;
// Process chunks in batches based on maxConcurrentChunks
const totalBatches = Math.ceil(
textChunks.length / this.maxConcurrentChunks
);
let currentBatch = 0;
for (let i = 0; i < textChunks.length; i += this.maxConcurrentChunks) {
const batch = textChunks.slice(i, i + this.maxConcurrentChunks);
currentBatch++;View on GitHub (pinned to 526360e320)
Solutions
- Ensure Ollama is running: `ollama serve` or the app, and curl http://<host>:11434 returns 'Ollama is running'
- Fix EMBEDDING_BASE_PATH to the correct reachable host/port
- In Docker use host.docker.internal:11434 or --network host
- If OLLAMA_AUTH_TOKEN is set, make sure it matches the daemon's expected token, or unset it for a local unauthed daemon
Example fix
// before EMBEDDING_BASE_PATH=http://localhost:11434 // (in Docker, localhost != host) // after EMBEDDING_BASE_PATH=http://host.docker.internal:11434 // and confirm `curl http://host.docker.internal:11434` succeeds
Defensive patterns
Strategy: retry
Validate before calling
// ping the daemon exactly like #isAlive before the bulk run
async function ollamaAlive(basePath, token) {
const headers = token ? { Authorization: `Bearer ${token}` } : {};
try { const r = await fetch(basePath, { headers }); return r.ok; }
catch { return false; }
} Type guard
function isOllamaUnreachable(e) {
return e instanceof Error && /Ollama service could not be reached/.test(e.message);
} Try / catch
try {
return await embedder.embedChunks(chunks);
} catch (e) {
if (!/could not be reached/.test(e.message)) throw e;
await new Promise(r => setTimeout(r, 2000));
return await embedder.embedChunks(chunks);
} Prevention
- Run `ollama serve` / the app and keep it up for the whole ingest.
- Confirm reachability from the AnythingLLM process (mind Docker networking).
- Match OLLAMA_AUTH_TOKEN to the daemon, or unset for a local unauthed daemon.
When it happens
Trigger: embedChunks called and #isAlive resolves false: Ollama daemon not running; wrong host/port in EMBEDDING_BASE_PATH; connection refused/firewalled; OLLAMA_AUTH_TOKEN set but mismatched so the ping 401s (res.ok false); TLS/DNS failure for a remote Ollama host; fetch itself throws and the .catch returns false.
Common situations: Ollama not started (`ollama serve` not running); AnythingLLM in a container that cannot reach the host's 11434; remote Ollama behind a proxy requiring auth; OLLAMA_HOST changed on the Ollama side but AnythingLLM env not updated; transient network blip to a remote instance.
Related errors
- LMStudio service could not be reached. Is LMStudio running?
- LiteLLM Failed to embed: ${error}
- LocalAI Failed to embed: ${error}
- Ollama returned empty embeddings for batch!
- Ollama Failed to embed: ${error}
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/e01dbd01db259f6d.
Report an issue: GitHub.