Mintplex-Labs/anything-llm · error · Error
LMStudio service could not be reached. Is LMStudio running?
Error message
LMStudio service could not be reached. Is LMStudio running?
What it means
Thrown at the start of embedChunks (line 50) when the private #isAlive() check returns false. #isAlive calls lmstudio.models.list() and treats a thrown error or an empty model list as dead. This preflight prevents queuing many embeddings against a server that cannot respond, since LMStudio is known to drop queued requests.
Source
Thrown at server/utils/EmbeddingEngines/lmstudio/index.js:51
return await this.lmstudio.models
.list()
.then((res) => res?.data?.length > 0)
.catch((e) => {
this.log(e.message);
return false;
});
}
async embedTextInput(textInput) {
const result = await this.embedChunks(
Array.isArray(textInput) ? textInput : [textInput]
);
return result?.[0] || [];
}
async embedChunks(textChunks = []) {
if (!(await this.#isAlive()))
throw new Error(
`LMStudio service could not be reached. Is LMStudio running?`
);
this.log(
`Embedding ${textChunks.length} chunks of text with ${this.model}.`
);
// LMStudio will drop all queued requests now? So if there are many going on
// we need to do them sequentially or else only the first resolves and the others
// get dropped or go unanswered >:(
let results = [];
let hasError = false;
for (const [idx, chunk] of textChunks.entries()) {
if (hasError) break;
results.push(
await this.lmstudio.embeddings
.create({
model: this.model,View on GitHub (pinned to 526360e320)
Solutions
- Open LMStudio and confirm the local server is started and a model is loaded (a loaded model is required — an empty list also fails #isAlive)
- Verify EMBEDDING_BASE_PATH is reachable from the AnythingLLM process: curl http://<host>:<port>/v1/models
- If AnythingLLM runs in Docker, use host.docker.internal instead of localhost, or run with --network host
- Check LMSTUDIO_AUTH_TOKEN matches the token configured in LMStudio's server settings
Example fix
// before EMBEDDING_BASE_PATH=http://localhost:1234/v1 // LMStudio server not started // after EMBEDDING_BASE_PATH=http://localhost:1234/v1 // (in Docker) ensure LMStudio started + model loaded EMBEDDING_BASE_PATH=http://host.docker.internal:1234/v1
Defensive patterns
Strategy: retry
Validate before calling
// reachability check before calling embedChunks
async function lmstudioAlive(openai) {
try {
const res = await openai.models.list();
return (res?.data?.length ?? 0) > 0;
} catch { return false; }
} Type guard
function isUnreachableError(e) {
return e instanceof Error && /LMStudio 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;
// wait for the user/server to come back, then retry once
await new Promise(r => setTimeout(r, 2000));
return await embedder.embedChunks(chunks);
} Prevention
- Start LMStudio's server and keep a model loaded for the whole ingest.
- Confirm reachability from the AnythingLLM process, not just the browser.
- Don't run concurrent AnythingLLM jobs against single-threaded LMStudio.
When it happens
Trigger: embedChunks is called and #isAlive() resolves false. Causes: LMStudio server process not running; wrong host/port in EMBEDDING_BASE_PATH; firewall/connection refused; LMStudio running but no model loaded (models.list returns empty data, length 0); CORS or network isolation between AnythingLLM and LMStudio; LMSTUDIO_AUTH_TOKEN mismatch causing a 401 that the .catch turns into false.
Common situations: User forgot to click 'Start Server' in LMStudio; LMStudio was quit/crashed; model was unloaded; AnythingLLM in a container that cannot reach host.docker.internal:1234; the port changed after an LMStudio update.
Related errors
- Ollama service could not be reached. Is Ollama running?
- LiteLLM Failed to embed: ${error}
- LMStudio Failed to embed: ${Array.from(uniqueErrors).join(",
- LocalAI Failed to embed: ${error}
- AnthropicLLM::getChatCompletion failed to communicate with A
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/b3fa7cab01aa4fdc.
Report an issue: GitHub.