jackwener/OpenCLI · error · UnsupportedDaemonPortEnvError

OPENCLI_DAEMON_PORT is no longer supported${suffix}. The Ope

Error message

OPENCLI_DAEMON_PORT is no longer supported${suffix}. The OpenCLI Chrome extension can only connect to localhost:${DEFAULT_DAEMON_PORT}. Unset OPENCLI_DAEMON_PORT and rerun opencli.

What it means

OpenCLI's daemon transport no longer supports overriding the daemon port via the OPENCLI_DAEMON_PORT environment variable. The Chrome extension hard-codes its connection to the default daemon port, so any non-empty OPENCLI_DAEMON_PORT value makes assertSupportedDaemonPortEnv throw UnsupportedDaemonPortEnvError before a daemon request is made.

Source

Thrown at src/browser/daemon-transport.ts:16

import { DEFAULT_DAEMON_PORT, isIgnorableDaemonPortEnv, unsupportedDaemonPortEnvMessage } from '../constants.js';

const DAEMON_PORT = DEFAULT_DAEMON_PORT;
const DAEMON_URL = `http://127.0.0.1:${DAEMON_PORT}`;
const OPENCLI_HEADERS = { 'X-OpenCLI': '1' };

class UnsupportedDaemonPortEnvError extends Error {
  constructor(value: string) {
    super(unsupportedDaemonPortEnvMessage(value));
    this.name = 'UnsupportedDaemonPortEnvError';
  }
}

function assertSupportedDaemonPortEnv(): void {
  const value = process.env.OPENCLI_DAEMON_PORT;
  if (!isIgnorableDaemonPortEnv(value)) throw new UnsupportedDaemonPortEnvError(value!);
}

export interface DaemonStatus {
  ok: boolean;
  pid: number;
  uptime: number;
  daemonVersion?: string;
  extensionConnected: boolean;
  extensionVersion?: string;
  extensionCompatRange?: string;
  contextId?: string;
  profileRequired?: boolean;
  profileDisconnected?: boolean;
  profiles?: BrowserProfileStatus[];
  pending: number;
  commandResultUnknown?: number;
  memoryMB: number;
  port: number;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Unset the variable: `unset OPENCLI_DAEMON_PORT` in the current shell
  2. Remove `export OPENCLI_DAEMON_PORT=...` from ~/.bashrc, ~/.zshrc, .env files, or CI configuration
  3. Restart the terminal/CI job so the environment is clean and rerun `opencli`
  4. Verify the extension is pointed at localhost on the default daemon port

Example fix

// before (shell)
export OPENCLI_DAEMON_PORT=9333
opencli ...
// after (shell)
unset OPENCLI_DAEMON_PORT
opencli ...
Defensive patterns

Strategy: validation

Validate before calling

if (process.env.OPENCLI_DAEMON_PORT) {
  console.warn('OPENCLI_DAEMON_PORT is unsupported; unsetting it');
  delete process.env.OPENCLI_DAEMON_PORT;
}
await opencli.requestDaemon();

Type guard

function hasNoDaemonPortEnv(): boolean { return !process.env.OPENCLI_DAEMON_PORT; }

Try / catch

try { await requestDaemon(); }
catch (e) {
  if (e instanceof UnsupportedDaemonPortEnvError) {
    delete process.env.OPENCLI_DAEMON_PORT;
    await requestDaemon();
  } else throw e;
}

Prevention

When it happens

Trigger: Calling any daemon-backed operation (e.g. requestDaemon) while the OPENCLI_DAEMON_PORT environment variable is set to a value not considered ignorable (empty/undefined).

Common situations: Developers upgrading from an older OpenCLI version that allowed custom daemon ports and still export OPENCLI_DAEMON_PORT=9222 in shell rc files, CI configs, or .env files loaded into the Node process.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/ab5da76584770270. Report an issue: GitHub.