thedotmack/claude-mem · error · HostObserverUnavailableError

CLAUDE_MEM_HOST_OBSERVER_PORT=

Error message

CLAUDE_MEM_HOST_OBSERVER_PORT=${configured} has nothing listening. Start your OpenAI-compatible observer on that port, then rerun with --provider host.

What it means

If CLAUDE_MEM_HOST_OBSERVER_PORT is set but nothing at all is listening on that port, resolveHostObserverPort throws HostObserverUnavailableError telling you to start the observer first. Host mode never launches a server for you — it only connects to one you run yourself.

Solutions

  1. Start your OpenAI-compatible observer so it listens on the configured port.
  2. Confirm the port with `curl http://127.0.0.1:<port>/v1/models` and fix CLAUDE_MEM_HOST_OBSERVER_PORT if it points at the wrong port.
  3. Rerun with --provider host once the observer is up.

Example fix

# before
export CLAUDE_MEM_HOST_OBSERVER_PORT=4141  # observer not running
cmem memory --provider host  # throws
// after
my-observer --port 4141 &
cmem memory --provider host
Defensive patterns

Strategy: retry

Validate before calling

const port = Number(process.env.CLAUDE_MEM_HOST_OBSERVER_PORT);
if (port) { try { const r = await fetch(`http://127.0.0.1:${port}/v1/models`); if (!r.ok) throw new Error('not OpenAI-compatible'); } catch { console.error(`nothing healthy on ${port}; start your observer first`); process.exit(1); } }

Try / catch

try { resolveHostObserverPort(workerPort); } catch (e) { if (e instanceof HostObserverUnavailableError && /nothing listening/.test(e.message)) { await startObserver(); /* then retry once */ } else throw e; }

Prevention

When it happens

Trigger: CLAUDE_MEM_HOST_OBSERVER_PORT names a valid, non-worker port, but probe(configured) finds no listener ('nothing listening').

Common situations: Observer process not started yet, crashed, or exited; wrong port typed in the env var; observer bound on a different machine/interface while the env var implies localhost.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17). Data as JSON: /api/errors/e6947f4b586b9e03. Report an issue: GitHub.

Appendix: source

Thrown at src/npx-cli/cmem-memory-credentials.ts:253

    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.`,
  );
}

export function buildHostObserverSettings(
  observerModel: 'cursor' | 'grok-bot',
  settings: SettingsLike,

View on GitHub (pinned to d8bc9755e7)