{"record":{"id":"baa1db3d19f83413","repo":"vitest-dev/vitest","slug":"inspector-host-cannot-be-a-url-use-host-port-in","errorCode":null,"errorMessage":"Inspector host cannot be a URL. Use \"host:port\" instead of \"${inspect}\"","messagePattern":"Inspector host cannot be a URL\\. Use \"host:port\" instead of \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/config/resolveConfig.ts","lineNumber":77,"sourceCode":"export function findConfigFile(root: string): string | undefined {\n  for (const configFile of configFiles) {\n    const configPath = resolve(root, configFile)\n    if (existsSync(configPath)) {\n      return configPath\n    }\n  }\n}\n\nfunction parseInspector(inspect: string | undefined | boolean | number) {\n  if (typeof inspect === 'boolean' || inspect === undefined) {\n    return {}\n  }\n  if (typeof inspect === 'number') {\n    return { port: inspect }\n  }\n\n  if (/https?:\\//.test(inspect)) {\n    throw new Error(\n      `Inspector host cannot be a URL. Use \"host:port\" instead of \"${inspect}\"`,\n    )\n  }\n\n  const [host, port] = inspect.split(':')\n  if (!port) {\n    return { host }\n  }\n  return { host, port: Number(port) || defaultInspectPort }\n}\n\nexport function resolveApiServerConfig(\n  config: UserConfig,\n  defaultPort: number,\n  logger: Logger,\n): ApiConfig {\n  const isBrowserEnabled = !!config.browser?.enabled\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/config/resolveConfig.ts#L59-L95","documentation":"`parseInspector` converts the `--inspect`/`--inspect-brk` value into `{ host, port }`. It accepts a boolean, a number (treated as a port), or a `host:port` string — but explicitly rejects values that look like a URL (`/https?:\\//`). The fix is to drop the scheme and pass `host:port`.","triggerScenarios":"Running `vitest --inspect=http://localhost:9229`, `--inspect-brk=ws://host:9229`, or pasting a DevTools URL from another tool. The regex test trips before host/port splitting.","commonSituations":"Copy-pasting a Chrome DevTools `ws://` URL; confusing Vitest's `--inspect` with `node --inspect`; tooling that emits URLs for inspector connections.","solutions":["Pass `host:port`: `vitest --inspect=localhost:9229`.","Pass just a port: `vitest --inspect=9229`.","Use bare `--inspect` to enable with defaults."],"exampleFix":"# before\nvitest --inspect=http://localhost:9229\n\n# after\nvitest --inspect=localhost:9229","handlingStrategy":"validation","validationCode":"function parseInspectValue(v: unknown): { host?: string; port?: number } {\n  if (typeof v === 'boolean' || v == null) return {}\n  if (typeof v === 'number') return { port: v }\n  const s = String(v)\n  if (/^https?:\\/\\//.test(s)) {\n    throw new Error('Pass host:port to --inspect, not a URL')\n  }\n  const [host, port] = s.split(':')\n  return port ? { host, port: Number(port) || 9229 } : { host }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass `--inspect=host:port` or `--inspect=port`, never a URL.","Differentiate Vitest's `--inspect` from Chrome DevTools `ws://` URLs.","Validate inspector input in wrapper scripts before forwarding to Vitest."],"tags":["config","inspector","debug","cli"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}