rohitg00/agentmemory · error

Engine not responding on :${port}, but ${survivors.size} pro

Error message

Engine not responding on :${port}, but ${survivors.size} process(es) still hold the port or pidfile: ${[...survivors].join(", ")}

What it means

Fatal stop-flow warning: the engine does not respond on the port (not actually serving), but one or more processes still hold the port or are referenced by the pidfile/worker pidfile. The CLI preserves state files and exits 1 so the user can investigate instead of blindly killing.

Source

Thrown at src/cli.ts:3554

      // instead of preserving for manual cleanup.
      const s = p.spinner();
      s.start(`Stopping orphaned agentmemory worker (pid ${workerPid})...`);
      const ok = await signalAndWait(workerPid, "SIGTERM", 3000);
      s.stop(ok ? `Stopped worker pid ${workerPid}` : `Failed to stop worker pid ${workerPid}`);
      clearEnginePidfile();
      clearEngineState();
      clearWorkerPidfile();
      if (!ok) {
        p.log.error(`Worker pid ${workerPid} survived SIGKILL. Investigate with \`ps\`.`);
        process.exit(1);
      }
      p.outro("Stopped orphaned worker. Memories persisted to disk.");
      return;
    }
    const survivors = new Set<number>(portPids);
    if (pidfilePid) survivors.add(pidfilePid);
    if (workerPid) survivors.add(workerPid);
    p.log.warn(
      `Engine not responding on :${port}, but ${survivors.size} process(es) still hold the port or pidfile: ${[...survivors].join(", ")}`,
    );
    p.log.info(
      `Preserving ~/.agentmemory/iii.pid + worker.pid. Investigate before manual cleanup:\n  ps -p ${[...survivors].join(",")} -o pid,ppid,comm,etime\n  ${IS_WINDOWS ? "netstat -ano | findstr :" + port : "lsof -i :" + port}`,
    );
    process.exit(1);
  }

  if (!state) {
    const compose = discoverComposeFile();
    if (compose && pidfilePid === null) {
      if (force) {
        p.log.warn(
          `--force: bypassing Docker-heuristic guard. Falling back to native pidfile + lsof on :${port}.`,
        );
      } else {
        p.log.error(
          `Engine is running on :${port} but no pidfile or state file is present. It may have been started via Docker compose by a different shell. Refusing to signal host PIDs.\n\nStop it with:\n  docker compose -f ${compose} down\n\nOr re-run with --force to signal whatever lsof finds on :${port}, or AGENTMEMORY_USE_DOCKER=1 to record state next time.`,

View on GitHub (pinned to e04ba88819)

Solutions

  1. Inspect the listed pids: ps -p <pids> -o pid,ppid,comm,etime and lsof -i :<port>
  2. Kill the confirmed survivors manually: kill <pid> (or kill -9 if needed)
  3. If the pids are stale/unrelated, remove ~/.agentmemory/iii.pid and worker.pid, then restart the engine
  4. Re-run with --force to bypass the guard once you understand the situation
Defensive patterns

Strategy: fallback

Validate before calling

lsof -i :49134 && ps -p $(cat ~/.agentmemory/iii.pid) -o pid,ppid,comm,etime 2>/dev/null || echo "stale pidfile"

Prevention

When it happens

Trigger: Port PIDs or pidfile/worker pids exist, but health check on the port fails — hung processes, stale pidfile pointing at a live unrelated process, or half-dead engine.

Common situations: Engine crashed without cleanup leaving orphaned listeners; another app bound the port; process in uninterruptible (D) state; container port mapping.

Related errors


AI-assisted analysis of rohitg00/agentmemory@e04ba88819 (2026-08-30). Data as JSON: /api/errors/a58e741cd41e4e69. Report an issue: GitHub.