microsoft/playwright · error · Error

Init page file does not exist: ${page}

Error message

Init page file does not exist: ${page}

What it means

Thrown by validateBrowserConfig() for each entry in browser.initPage that does not point to an existing file, checked via fileExistsAsync. initPage entries are HTML files loaded as an initial page when the browser starts; a missing file would leave the MCP server with no page to operate on. The check happens before launch so the failure is explicit.

Source

Thrown at packages/playwright-core/src/tools/mcp/config.ts:246

    if (process.platform === 'linux')
      browser.launchOptions.chromiumSandbox = browser.launchOptions.channel !== 'chromium' && browser.launchOptions.channel !== 'chrome-for-testing';
    else
      browser.launchOptions.chromiumSandbox = true;
  }

  if (browser.isolated && browser.userDataDir)
    throw new Error('Browser userDataDir is not supported in isolated mode.');

  if (browser.initScript) {
    for (const script of browser.initScript) {
      if (!await fileExistsAsync(script))
        throw new Error(`Init script file does not exist: ${script}`);
    }
  }
  if (browser.initPage) {
    for (const page of browser.initPage) {
      if (!await fileExistsAsync(page))
        throw new Error(`Init page file does not exist: ${page}`);
    }
  }
  if (browser.contextOptions.viewport === undefined) {
    if (browser.launchOptions.headless)
      browser.contextOptions.viewport = { width: 1280, height: 720 };
    else
      browser.contextOptions.viewport = null;
  }

  if (browserName === 'chromium') {
    browser.launchOptions.args = browser.launchOptions.args ?? [];
    if (!browser.launchOptions.args.some(a => a.includes('--disable-blink-features')))
      browser.launchOptions.args.push(`--disable-blink-features=AutomationControlled`);
  }

  return { ...browser, browserName };
}

View on GitHub (pinned to c8fc3bf8d3)

Solutions

  1. Confirm the file exists at the resolved path printed in the error, from the same directory the MCP server starts in.
  2. Switch to an absolute path to eliminate cwd-dependent resolution.
  3. Re-check the filename for typos and case sensitivity (relevant on Linux).
  4. Ensure the file is readable by the process user.

Example fix

// before
--init-page ./pages/start.html
// after
--init-page /srv/app/pages/start.html
Defensive patterns

Strategy: validation

Validate before calling

import fs from 'fs';
const ok = initPagePaths.every(p => fs.existsSync(p));
if (!ok) {
  throw new Error(`Missing init page files: ${initPagePaths.filter(p => !fs.existsSync(p)).join(', ')}`);
}

Type guard

function isExistingFile(p: string): boolean {
  try { return fs.statSync(p).isFile(); } catch { return false; }
}

Prevention

When it happens

Trigger: Passing --init-page ./welcome.html (or browser.initPage in config) where the HTML file does not exist or is not readable.

Common situations: HTML file moved or renamed; relative path resolved from the wrong cwd; file committed with a path that only exists on another developer's machine; typo in the filename.

Related errors


AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12). Data as JSON: /api/errors/38fe899887b52041. Report an issue: GitHub.