{"record":{"id":"0928c3a5256aa1b6","repo":"can1357/oh-my-pi","slug":"cannot-reach-vmond-at-url-detail-ensure-vm","errorCode":null,"errorMessage":"Cannot reach vmond at ${url}: ${detail}. Ensure vmon serve is running and the URL/token are correct.","messagePattern":"Cannot reach vmond at (.+?): (.+?)\\. Ensure vmon serve is running and the URL/token are correct\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/metaharness/src/tb/cli.ts","lineNumber":302,"sourceCode":"\ttry {\n\t\tconst url = new URL(gatewayUrl);\n\t\turl.pathname = \"/healthz\";\n\t\turl.search = \"\";\n\t\turl.hash = \"\";\n\t\tconst response = await fetch(url, { signal: AbortSignal.timeout(3_000) });\n\t\tif (!response.ok) console.warn(`warning: gateway health probe returned HTTP ${response.status}`);\n\t} catch (error) {\n\t\tconsole.warn(`warning: gateway health probe failed: ${error instanceof Error ? error.message : String(error)}`);\n\t}\n}\n\nasync function preflightVmon(url: string, token: string): Promise<void> {\n\tconst client = connect(url, { token: token || undefined });\n\ttry {\n\t\tawait client.health();\n\t} catch (error) {\n\t\tconst detail = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(\n\t\t\t`Cannot reach vmond at ${url}: ${detail}. Ensure vmon serve is running and the URL/token are correct.`,\n\t\t);\n\t} finally {\n\t\tawait client.close();\n\t}\n}\n\nfunction trialRow(epoch: number, item: WorkItem, result: TrialResult, trialDir: string, startedAt: number): TrialRow {\n\treturn {\n\t\tepoch,\n\t\tmodel: item.model,\n\t\ttask: item.task.name,\n\t\tattempt: item.attempt,\n\t\tstatus: result.status,\n\t\treward: result.reward,\n\t\tagentTimedOut: result.agentTimedOut,\n\t\tinputTokens: result.usage.input,\n\t\toutputTokens: result.usage.output,","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/metaharness/src/tb/cli.ts#L284-L320","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Start the daemon: run 'vmon serve' (verify it listens on the expected port)","Check --vmon-url correctness (scheme, host, port) and curl the health endpoint","Verify the token is current and passed correctly; retry once the daemon is reachable"],"exampleFix":"// before\nawait preflightVmon(\"http://localhost:9999\", token) // nothing listening\n// after\n$ vmon serve --port 9999 &\nawait preflightVmon(\"http://localhost:9999\", token)","handlingStrategy":"try-catch","validationCode":"// optionally probe first\nconst res = await fetch(`${url.replace(/\\/$/, \"\")}/health`).catch(() => null);\nif (!res || !res.ok) throw new Error(`vmond unreachable at ${url}`);","typeGuard":null,"tryCatchPattern":"try {\n  await preflightVmon(url, token);\n} catch (err) {\n  console.error(`vmond preflight failed: ${err.message}. Is 'vmon serve' running?`);\n  process.exit(1);\n}","preventionTips":["Start 'vmon serve' before running the harness","Health-check the URL with curl before long runs","Keep tokens in env/config and rotate them before expiry","Use explicit host/port, not localhost, in containers"],"tags":["network","connectivity","health-check"],"backgroundTag":"connection-refused","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}