microsoft/playwright · error · Error

No device with serial number '${options.deviceSerialNumber}'

Error message

No device with serial number '${options.deviceSerialNumber}' was found

What it means

Thrown by AndroidServerLauncherImpl.launchServer after filtering devices by `options.deviceSerialNumber` yields zero matches. The supplied serial does not correspond to any currently visible device.

Source

Thrown at packages/playwright-core/src/androidServerImpl.ts:44

export class AndroidServerLauncherImpl {
  async launchServer(options: LaunchAndroidServerOptions = {}): Promise<BrowserServer> {
    const playwright = createPlaywright({ sdkLanguage: 'javascript', isServer: true });
    // 1. Pre-connect to the device
    const controller = new ProgressController();
    let devices = await controller.run(progress => playwright.android.devices(progress, {
      host: options.adbHost,
      port: options.adbPort,
      omitDriverInstall: options.omitDriverInstall,
    }));

    if (devices.length === 0)
      throw new Error('No devices found');

    if (options.deviceSerialNumber) {
      devices = devices.filter(d => d.serial === options.deviceSerialNumber);
      if (devices.length === 0)
        throw new Error(`No device with serial number '${options.deviceSerialNumber}' was found`);
    }

    if (devices.length > 1)
      throw new Error(`More than one device found. Please specify deviceSerialNumber`);

    const device = devices[0];

    const path = options.wsPath ? (options.wsPath.startsWith('/') ? options.wsPath : `/${options.wsPath}`) : `/${createGuid()}`;

    // 2. Start the server
    const server = new PlaywrightServer({ mode: 'launchServer', path, maxConnections: 1, preLaunchedAndroidDevice: device });
    const wsEndpoint = await server.listen(options.port, options.host);

    // 3. Return the BrowserServer interface
    const browserServer = new EventEmitter() as BrowserServer & EventEmitter;
    browserServer.wsEndpoint = () => wsEndpoint;
    browserServer.close = () => device.close(nullProgress);
    browserServer.kill = () => device.close(nullProgress);

View on GitHub (pinned to c8fc3bf8d3)

Solutions

  1. Run `adb devices -l` and copy the exact serial from the first column.
  2. For emulators use the `emulator-<port>` serial form.
  3. Authorize the device (accept the USB debugging prompt) so it appears in the device list.

Example fix

# before
node launch-android.js --device-serial-number=XYZ123  # typo

# after
$ adb devices -l
# emulator-5554 device
node launch-android.js --device-serial-number=emulator-5554
Defensive patterns

Strategy: validation

Validate before calling

import { execSync } from 'child_process';
function assertSerialKnown(serial: string) {
  const out = execSync('adb devices', { encoding: 'utf8' });
  if (!new RegExp(`^${serial}\\s+device`, 'm').test(out))
    throw new Error(`Serial ${serial} not in 'adb devices'; verify with adb devices -l`);
}

Type guard

function isValidSerial(serial: string, adbOutput: string): boolean {
  return new RegExp(`^${serial}\\s+device`, 'm').test(adbOutput);
}

Try / catch

try {
  return await android.launchServer(options);
} catch (e) {
  if (/No device with serial number/.test(e.message)) {
    console.error(`Run 'adb devices -l' and correct --device-serial-number`);
    process.exit(5);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling `android.launchServer({ deviceSerialNumber: 'XYZ123' })` where no connected device has `serial === 'XYZ123'`. The filter `devices.filter(d => d.serial === options.deviceSerialNumber)` returns an empty array.

Common situations: Wrong serial (typo, stale config); device disconnected before launch; emulator serial mismatch; copied serial from a different machine's adb output.

Related errors


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