{"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/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/node/config/resolveConfig.ts#L59-L95","documentation":"Thrown by parseInspector() when the `--inspect` (or api/server inspect) value looks like a URL (matches /https?:\\//). Node's inspector expects a `host:port` string, not a URL with a scheme; passing a URL would fail silently or connect to the wrong target, so Vitest rejects it up front.","triggerScenarios":"Passing `--inspect=http://localhost:9229` or `--inspect=https://host:9229` on the CLI or in config. The regex /https?:\\// matches and the error fires, telling the user to drop the scheme.","commonSituations":"Copy-pasting a DevTools `chrome://inspect` URL or a ws:// debugger URL into --inspect; assuming --inspect takes a full inspector-protocol URL; config migrated from a browser-DevTools setup.","solutions":["Use host:port form without a scheme: `--inspect=localhost:9229` or `--inspect=127.0.0.1:9229`.","For just a port, pass a number: `--inspect=9229`.","If you need a ws:// inspector URL for a custom client, configure it at the transport layer, not via --inspect."],"exampleFix":"# before\nvitest --inspect=http://localhost:9229\n# after\nvitest --inspect=localhost:9229","handlingStrategy":"validation","validationCode":"function parseInspect(v: string): string {\n  if (/https?:\\/\\//.test(v)) {\n    throw new Error('inspect must be host:port, not a URL')\n  }\n  return v\n}","typeGuard":"function isHostPort(v: unknown): v is string {\n  return typeof v === 'string' && !/https?:\\/\\//.test(v)\n}","tryCatchPattern":null,"preventionTips":["Pass --inspect as host:port (e.g. localhost:9229) or a bare port number.","Never paste a chrome://inspect or ws:// URL into --inspect.","Validate inspector config strings before launching Vitest."],"tags":[],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}