{"record":{"id":"0ea0159e089e40bc","repo":"thedotmack/claude-mem","slug":"claude-mem-host-observer-port-configured-is-occ","errorCode":null,"errorMessage":"CLAUDE_MEM_HOST_OBSERVER_PORT=${configured} is occupied by a process that is not an OpenAI-compatible observer. Stop that process or point CLAUDE_MEM_HOST_OBSERVER_PORT at your observer.","messagePattern":"CLAUDE_MEM_HOST_OBSERVER_PORT=(.+?) is occupied by a process that is not an OpenAI-compatible observer\\. Stop that process or point CLAUDE_MEM_HOST_OBSERVER_PORT at your observer\\.","errorType":"exception","errorClass":"HostObserverUnavailableError","httpStatus":null,"severity":"error","filePath":"src/npx-cli/cmem-memory-credentials.ts","lineNumber":249,"sourceCode":"): string {\n  const worker = parsePort(typeof workerPort === 'number' ? workerPort : nonEmptyString(workerPort));\n  const configuredRaw = nonEmptyString(env.CLAUDE_MEM_HOST_OBSERVER_PORT);\n  if (configuredRaw) {\n    const configured = parsePort(configuredRaw);\n    if (configured == null) {\n      throw new HostObserverUnavailableError(\n        `CLAUDE_MEM_HOST_OBSERVER_PORT=${configuredRaw} is not a valid port. Set it to the port your OpenAI-compatible observer already listens on.`,\n      );\n    }\n    if (worker != null && configured === worker) {\n      throw new HostObserverUnavailableError(\n        `CLAUDE_MEM_HOST_OBSERVER_PORT=${configured} is the claude-mem worker port. Point it at your OpenAI-compatible observer instead.`,\n      );\n    }\n    const status = probe(configured);\n    if (status === 'observer') return String(configured);\n    if (status === 'occupied') {\n      throw new HostObserverUnavailableError(\n        `CLAUDE_MEM_HOST_OBSERVER_PORT=${configured} is occupied by a process that is not an OpenAI-compatible observer. Stop that process or point CLAUDE_MEM_HOST_OBSERVER_PORT at your observer.`,\n      );\n    }\n    throw new HostObserverUnavailableError(\n      `CLAUDE_MEM_HOST_OBSERVER_PORT=${configured} has nothing listening. Start your OpenAI-compatible observer on that port, then rerun with --provider host.`,\n    );\n  }\n\n  const candidates = hostObserverCandidatePorts(workerPort, env);\n  for (const port of candidates) {\n    const status = probe(port);\n    if (status === 'observer') return String(port);\n  }\n\n  throw new HostObserverUnavailableError(\n    `No OpenAI-compatible host observer is listening on 127.0.0.1:${candidates.join(' or ') || HOST_OBSERVER_DEFAULT_PORT}. Host mode uses an observer you already run; claude-mem does not start one. Start your observer, then rerun with --provider host. If it uses another port, set CLAUDE_MEM_HOST_OBSERVER_PORT.`,\n  );\n}","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/npx-cli/cmem-memory-credentials.ts#L231-L267","documentation":"When CLAUDE_MEM_HOST_OBSERVER_PORT is set, resolveHostObserverPort probes that TCP port and classifies the listener. If something is listening but it does not respond like an OpenAI-compatible observer, the library throws rather than sending memory requests to the wrong service. This protects against silently posting embeddings/chat requests to an unrelated process.","triggerScenarios":"CLAUDE_MEM_HOST_OBSERVER_PORT is set to a port where another application (dev server, database, UI) is bound, and the probe returns 'occupied' instead of 'observer'.","commonSituations":"Port reuse: the observer was stopped and another tool grabbed the port; the port belongs to a non-OpenAI HTTP service; a stale observer instance was replaced by something else.","solutions":["Stop the non-observer process listening on the configured port (find it with `lsof -i :<port>` or `ss -ltnp`).","Set CLAUDE_MEM_HOST_OBSERVER_PORT to the port your actual OpenAI-compatible observer listens on.","Restart your observer on the configured port and rerun with --provider host."],"exampleFix":"# before\nCLAUDE_MEM_HOST_OBSERVER_PORT=3000   # Next.js dev server bound here\n# after\nCLAUDE_MEM_HOST_OBSERVER_PORT=4141   # observer's real port\nlsof -i :3000  # identify and stop the squatter if the port must stay","handlingStrategy":"validation","validationCode":"import { createConnection } from 'node:net';\nfunction portInUse(port: number): Promise<boolean> { return new Promise(res => { const s = createConnection(port, '127.0.0.1'); s.once('connect', () => { s.destroy(); res(true); }); s.once('error', () => res(false)); }); }\nconst p = Number(process.env.CLAUDE_MEM_HOST_OBSERVER_PORT);\nif (p && await portInUse(p)) console.warn(`port ${p} occupied — ensure it is your observer`);","typeGuard":null,"tryCatchPattern":"try { resolveHostObserverPort(workerPort); } catch (e) { if (e instanceof HostObserverUnavailableError && /occupied/.test(e.message)) { execSync(`lsof -ti :${port}`); /* stop or reconfigure */ } else throw e; }","preventionTips":["Reserve the observer port exclusively; pick uncommon ports (e.g. 4141)","Check `lsof -i :<port>` after changing configs","Start the observer before tools that depend on it"],"tags":["ports","host-observer","port-conflict"],"backgroundTag":"address-already-in-use","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}