can1357/oh-my-pi · error

Cannot reach vmond at ${url}: ${detail}. Ensure vmon serve i

Error message

Cannot reach vmond at ${url}: ${detail}. Ensure vmon serve is running and the URL/token are correct.

What it means

preflightVmon performs a health check against the vmond control daemon before starting trials. If connect()/client.health() fails for any reason (DNS, TCP, TLS, auth), the original error is wrapped in this message with instructions to verify the daemon, URL, and token. The client is always closed in finally.

Source

Thrown at packages/metaharness/src/tb/cli.ts:302

	try {
		const url = new URL(gatewayUrl);
		url.pathname = "/healthz";
		url.search = "";
		url.hash = "";
		const response = await fetch(url, { signal: AbortSignal.timeout(3_000) });
		if (!response.ok) console.warn(`warning: gateway health probe returned HTTP ${response.status}`);
	} catch (error) {
		console.warn(`warning: gateway health probe failed: ${error instanceof Error ? error.message : String(error)}`);
	}
}

async function preflightVmon(url: string, token: string): Promise<void> {
	const client = connect(url, { token: token || undefined });
	try {
		await client.health();
	} catch (error) {
		const detail = error instanceof Error ? error.message : String(error);
		throw new Error(
			`Cannot reach vmond at ${url}: ${detail}. Ensure vmon serve is running and the URL/token are correct.`,
		);
	} finally {
		await client.close();
	}
}

function trialRow(epoch: number, item: WorkItem, result: TrialResult, trialDir: string, startedAt: number): TrialRow {
	return {
		epoch,
		model: item.model,
		task: item.task.name,
		attempt: item.attempt,
		status: result.status,
		reward: result.reward,
		agentTimedOut: result.agentTimedOut,
		inputTokens: result.usage.input,
		outputTokens: result.usage.output,

View on GitHub (pinned to 9690622007)

Solutions

  1. Start the daemon: run 'vmon serve' (verify it listens on the expected port)
  2. Check --vmon-url correctness (scheme, host, port) and curl the health endpoint
  3. Verify the token is current and passed correctly; retry once the daemon is reachable

Example fix

// before
await preflightVmon("http://localhost:9999", token) // nothing listening
// after
$ vmon serve --port 9999 &
await preflightVmon("http://localhost:9999", token)
Defensive patterns

Strategy: try-catch

Validate before calling

// optionally probe first
const res = await fetch(`${url.replace(/\/$/, "")}/health`).catch(() => null);
if (!res || !res.ok) throw new Error(`vmond unreachable at ${url}`);

Try / catch

try {
  await preflightVmon(url, token);
} catch (err) {
  console.error(`vmond preflight failed: ${err.message}. Is 'vmon serve' running?`);
  process.exit(1);
}

Prevention

When it happens

Trigger: Calling main/preflightVmon when vmon serve is not running, the --vmon-url points at the wrong host/port, the URL is malformed, the auth token is wrong/missing, or a firewall blocks the connection.

Common situations: Forgot to start 'vmon serve' before running the tb harness; stale URL after the daemon moved ports; expired or rotated token; running inside a container where localhost is not the host.

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 can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/0928c3a5256aa1b6. Report an issue: GitHub.