Skip to content

Headless isolated launch fails as root without --no-sandbox #261

Description

@mamoru127

Summary

Running chrome-devtools-mcp as the root user causes Chrome to exit immediately with Running as root without --no-sandbox is not supported, so the MCP client receives Target closed / Connection closed
errors.

Environment

  • chrome-devtools-mcp 0.6.0
  • Node.js 22.20.0
  • OS: Linux container (root user)
  • Command: node build/src/index.js --headless --isolated

Steps to Reproduce

  1. Checkout v0.6.0
  2. Run npm install && npm run build
  3. Execute node build/src/index.js --headless --isolated as root
  4. Observe Chrome crashing with the log above and the MCP server exiting

Expected Behavior

The bundled Chrome should launch successfully even when the server runs as root (typical for containers/CI), without requiring extra flags from the user.

Suggested Fix

Automatically add sandbox flags when running as root. For example in src/browser.ts:

const args = [
  ...(options.args ?? []),
  '--hide-crash-restore-bubble',
];

if (process.getuid?.() === 0 && !args.some(arg => arg.startsWith('--no-sandbox'))) {
  args.push('--no-sandbox', '--disable-setuid-sandbox');
}

Then rebuild (npm run build) so the generated build/src/browser.js picks up the same logic.

Activity

  1. wsxiaoys commented on Oct 5, 2025

    @wsxiaoys

    Encountering the same issue, can confirm the proposed solution works. it'll be nice to just allow passing additional args to chrome as launch args. e.g `--launch-arg="--no-sandbox --disable-setuid-sandbox"'

  2. OrKoN commented on Oct 10, 2025

    @OrKoN
    Collaborator

    Generally we cannot recommend running without Chrome sandboxes or turn them off automatically but we can allow passing additional args to Chrome. Started a PR here #261

  3. added a commit that references this issue on Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions