thedotmack/claude-mem · error · HostObserverUnavailableError
CLAUDE_MEM_HOST_OBSERVER_PORT=
Error message
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. What it means
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.
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.
Example fix
# before CLAUDE_MEM_HOST_OBSERVER_PORT=3000 # Next.js dev server bound here # after CLAUDE_MEM_HOST_OBSERVER_PORT=4141 # observer's real port lsof -i :3000 # identify and stop the squatter if the port must stay
Defensive patterns
Strategy: validation
Validate before calling
import { createConnection } from 'node:net';
function 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)); }); }
const p = Number(process.env.CLAUDE_MEM_HOST_OBSERVER_PORT);
if (p && await portInUse(p)) console.warn(`port ${p} occupied — ensure it is your observer`); Try / catch
try { resolveHostObserverPort(workerPort); } catch (e) { if (e instanceof HostObserverUnavailableError && /occupied/.test(e.message)) { execSync(`lsof -ti :${port}`); /* stop or reconfigure */ } else throw e; } Prevention
- 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
When it happens
Trigger: 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'.
Common situations: 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.
Related errors
- CLAUDE_MEM_HOST_OBSERVER_PORT=
- CLAUDE_MEM_HOST_OBSERVER_PORT=
- No OpenAI-compatible host observer is listening on 127.0.0.1
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/0ea0159e089e40bc.
Report an issue: GitHub.
Appendix: source
Thrown at src/npx-cli/cmem-memory-credentials.ts:249
): string {
const worker = parsePort(typeof workerPort === 'number' ? workerPort : nonEmptyString(workerPort));
const configuredRaw = nonEmptyString(env.CLAUDE_MEM_HOST_OBSERVER_PORT);
if (configuredRaw) {
const configured = parsePort(configuredRaw);
if (configured == null) {
throw new HostObserverUnavailableError(
`CLAUDE_MEM_HOST_OBSERVER_PORT=${configuredRaw} is not a valid port. Set it to the port your OpenAI-compatible observer already listens on.`,
);
}
if (worker != null && configured === worker) {
throw new HostObserverUnavailableError(
`CLAUDE_MEM_HOST_OBSERVER_PORT=${configured} is the claude-mem worker port. Point it at your OpenAI-compatible observer instead.`,
);
}
const status = probe(configured);
if (status === 'observer') return String(configured);
if (status === 'occupied') {
throw new HostObserverUnavailableError(
`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.`,
);
}
throw new HostObserverUnavailableError(
`CLAUDE_MEM_HOST_OBSERVER_PORT=${configured} has nothing listening. Start your OpenAI-compatible observer on that port, then rerun with --provider host.`,
);
}
const candidates = hostObserverCandidatePorts(workerPort, env);
for (const port of candidates) {
const status = probe(port);
if (status === 'observer') return String(port);
}
throw new HostObserverUnavailableError(
`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.`,
);
}View on GitHub (pinned to d8bc9755e7)