{"record":{"id":"b3fa7cab01aa4fdc","repo":"Mintplex-Labs/anything-llm","slug":"lmstudio-service-could-not-be-reached-is-lmstudio","errorCode":null,"errorMessage":"LMStudio service could not be reached. Is LMStudio running?","messagePattern":"LMStudio service could not be reached\\. Is LMStudio running\\?","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/EmbeddingEngines/lmstudio/index.js","lineNumber":51,"sourceCode":"    return await this.lmstudio.models\n      .list()\n      .then((res) => res?.data?.length > 0)\n      .catch((e) => {\n        this.log(e.message);\n        return false;\n      });\n  }\n\n  async embedTextInput(textInput) {\n    const result = await this.embedChunks(\n      Array.isArray(textInput) ? textInput : [textInput]\n    );\n    return result?.[0] || [];\n  }\n\n  async embedChunks(textChunks = []) {\n    if (!(await this.#isAlive()))\n      throw new Error(\n        `LMStudio service could not be reached. Is LMStudio running?`\n      );\n\n    this.log(\n      `Embedding ${textChunks.length} chunks of text with ${this.model}.`\n    );\n\n    // LMStudio will drop all queued requests now? So if there are many going on\n    // we need to do them sequentially or else only the first resolves and the others\n    // get dropped or go unanswered >:(\n    let results = [];\n    let hasError = false;\n    for (const [idx, chunk] of textChunks.entries()) {\n      if (hasError) break;\n      results.push(\n        await this.lmstudio.embeddings\n          .create({\n            model: this.model,","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/EmbeddingEngines/lmstudio/index.js#L33-L69","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nEMBEDDING_BASE_PATH=http://localhost:1234/v1\n// LMStudio server not started\n\n// after\nEMBEDDING_BASE_PATH=http://localhost:1234/v1\n// (in Docker) ensure LMStudio started + model loaded\nEMBEDDING_BASE_PATH=http://host.docker.internal:1234/v1","handlingStrategy":"retry","validationCode":"// reachability check before calling embedChunks\nasync function lmstudioAlive(openai) {\n  try {\n    const res = await openai.models.list();\n    return (res?.data?.length ?? 0) > 0;\n  } catch { return false; }\n}","typeGuard":"function isUnreachableError(e) {\n  return e instanceof Error && /LMStudio service could not be reached/.test(e.message);\n}","tryCatchPattern":"try {\n  return await embedder.embedChunks(chunks);\n} catch (e) {\n  if (!/could not be reached/.test(e.message)) throw e;\n  // wait for the user/server to come back, then retry once\n  await new Promise(r => setTimeout(r, 2000));\n  return await embedder.embedChunks(chunks);\n}","preventionTips":["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."],"tags":["lmstudio","embedding","network","runtime","preflight"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}