microsoft/playwright · error · Error

Launching more browsers is not allowed.

Error message

Launching more browsers is not allowed.

What it means

Thrown by ElectronDispatcher.launch() when _denyLaunch is true. ElectronDispatcher gets the same denyLaunch policy as BrowserType/Android dispatchers: a Playwright server that owns lifecycle (or a restricted connection) forbids the client from launching additional Electron applications. The check runs before any electron.spawn.

Source

Thrown at packages/playwright-core/src/server/dispatchers/electronDispatcher.ts:41

import type { PageDispatcher } from './pageDispatcher';
import type { ConsoleMessage } from '../console';
import type { Electron } from '../electron/electron';
import type * as channels from '../channels';
import type { Progress } from '../progress';


export class ElectronDispatcher extends Dispatcher<Electron, channels.ElectronChannel, RootDispatcher> implements channels.ElectronChannel {
  _type_Electron = true;
  _denyLaunch: boolean;

  constructor(scope: RootDispatcher, electron: Electron, denyLaunch: boolean) {
    super(scope, electron, 'Electron', {});
    this._denyLaunch = denyLaunch;
  }

  async launch(params: channels.ElectronLaunchParams, progress: Progress): Promise<channels.ElectronLaunchResult> {
    if (this._denyLaunch)
      throw new Error(`Launching more browsers is not allowed.`);
    const electronApplication = await this._object.launch(progress, params);
    return { electronApplication: new ElectronApplicationDispatcher(this, electronApplication) };
  }
}

export class ElectronApplicationDispatcher extends Dispatcher<ElectronApplication, channels.ElectronApplicationChannel, ElectronDispatcher> implements channels.ElectronApplicationChannel {
  _type_EventTarget = true;
  _type_ElectronApplication = true;
  private readonly _subscriptions = new Set<channels.ElectronApplicationUpdateSubscriptionParams['event']>();

  constructor(scope: ElectronDispatcher, electronApplication: ElectronApplication) {
    super(scope, electronApplication, 'ElectronApplication', {
      context: BrowserContextDispatcher.from(scope, electronApplication.context())
    });
    this.addObjectListener(ElectronApplication.Events.Close, () => {
      this._dispatchEvent('close');
      this._dispose();
    });

View on GitHub (pinned to c8fc3bf8d3)

Solutions

  1. Run electron.launch() from a local, unconstrained playwright instance rather than through a denyLaunch server connection.
  2. If the server is meant to provide Electron, have it pre-launch and hand the application back through the init result instead of letting the client spawn it.
  3. Switch the server to a mode without denyLaunch when client-side Electron launches are required.

Example fix

// before: launch Electron through a restricted server connection
const electron = (await playwright.connect(server)).electron;
const app = await electron.launch(); // denied

// after: launch Electron from a local instance
const { electron } = require('playwright');
const app = await electron.launch({ executablePath: '/path/to/app' });
Defensive patterns

Strategy: validation

Validate before calling

if (init.denyLaunch) throw new Error('Server denies electron.launch(); run Electron from a local playwright instance');

Try / catch

try {
  await playwright.electron.launch();
} catch (e) {
  if (/Launching more browsers is not allowed/.test(e.message)) { /* use local instance */ }
  else throw e;
}

Prevention

When it happens

Trigger: Calling playwright.electron.launch() (the Electron RPC) through a RootDispatcher/ElectronDispatcher constructed with denyLaunch=true — i.e. over a connection to a managed/restricted Playwright server. Fires immediately, before the Electron binary is located or spawned.

Common situations: Running Electron automation against a remote/restricted Playwright server that did not pre-authorize Electron launches; MCP/grid sessions with denyLaunch that try to start Electron from the client.

Related errors


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