{"record":{"id":"6c9eeb1667c1e14f","repo":"thedotmack/claude-mem","slug":"claude-mem-host-observer-port-configured-is-the","errorCode":null,"errorMessage":"CLAUDE_MEM_HOST_OBSERVER_PORT=${configured} is the claude-mem worker port. Point it at your OpenAI-compatible observer instead.","messagePattern":"CLAUDE_MEM_HOST_OBSERVER_PORT=(.+?) is the claude-mem worker port\\. Point it at your OpenAI-compatible observer instead\\.","errorType":"exception","errorClass":"HostObserverUnavailableError","httpStatus":null,"severity":"error","filePath":"src/npx-cli/cmem-memory-credentials.ts","lineNumber":242,"sourceCode":"\n/** Atomically move staged/current credentials into the active provider slot. */\n\nexport function resolveHostObserverPort(\n  workerPort: string | number | undefined,\n  env: NodeJS.ProcessEnv = process.env,\n  probe: HostObserverPortProbe = probeHostObserverPortSync,\n): 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);","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/8bc631a71a487424b866756e43a6efa4574cc66b/src/npx-cli/cmem-memory-credentials.ts#L224-L260","documentation":"The claude-mem worker itself listens on a port; if CLAUDE_MEM_HOST_OBSERVER_PORT points at that same port, host mode would route AI traffic back into claude-mem instead of your external observer. resolveHostObserverPort detects configured === workerPort and throws before probing, preventing a self-referential loop.","triggerScenarios":"Setting CLAUDE_MEM_HOST_OBSERVER_PORT equal to the worker port (CLAUDE_MEM_WORKER_PORT setting or the workerPort argument passed to resolveHostObserverPort), then running install with --provider host or buildHostObserverSettings.","commonSituations":"Copying CLAUDE_MEM_WORKER_PORT into the observer variable by mistake; assuming worker and observer can share a port; scripting the install from settings where both vars are identical.","solutions":["Point CLAUDE_MEM_HOST_OBSERVER_PORT at the port your external OpenAI-compatible observer actually listens on (e.g. 4141), not the worker port","Unset CLAUDE_MEM_HOST_OBSERVER_PORT so auto-discovery probes 37777/37778 (skipping the worker port automatically)","If your observer IS meant to be reached on another port, start it there first, then rerun install"],"exampleFix":"// before\nexport CLAUDE_MEM_WORKER_PORT=37777\nexport CLAUDE_MEM_HOST_OBSERVER_PORT=37777\n// after\nexport CLAUDE_MEM_WORKER_PORT=37777\nexport CLAUDE_MEM_HOST_OBSERVER_PORT=4141","handlingStrategy":"validation","validationCode":"const worker = Number(process.env.CLAUDE_MEM_WORKER_PORT);\nconst observer = Number(process.env.CLAUDE_MEM_HOST_OBSERVER_PORT);\nif (worker && observer && worker === observer) {\n  throw new Error('CLAUDE_MEM_HOST_OBSERVER_PORT must differ from the worker port');\n}","typeGuard":null,"tryCatchPattern":"try {\n  buildHostObserverSettings(model, settings, env);\n} catch (e) {\n  if (e instanceof HostObserverUnavailableError && e.message.includes('is the claude-mem worker port')) {\n    console.error('Observer port must not equal CLAUDE_MEM_WORKER_PORT; fix CLAUDE_MEM_HOST_OBSERVER_PORT.');\n  } else throw e;\n}","preventionTips":["Never copy CLAUDE_MEM_WORKER_PORT into CLAUDE_MEM_HOST_OBSERVER_PORT when templating configs","Keep the observer on a clearly different port than any claude-mem service","Script installs should assert the two env vars differ before invoking the CLI"],"tags":["configuration","port-conflict","host-observer","env-var"],"backgroundTag":"conflicting-config-options","analyzedSha":"8bc631a71a487424b866756e43a6efa4574cc66b","analyzedAt":"2026-09-09T10:47:06.009Z","contentChangedAt":"2026-09-09T10:47:06.009Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}