{"record":{"id":"0c2d15f1f28cebcf","repo":"microsoft/playwright","slug":"unable-to-open-x-display","errorCode":null,"errorMessage":"Unable to open X display!\n================================\nMost likely this is because there is no X server available.\nUse 'xvfb-run' on Linux to launch your tests with an emulated display server.\nFor example: 'xvfb-run npm run test:e2e'\n================================\n${progress.metadata.log}","messagePattern":"Unable to open X display!\n================================\nMost likely this is because there is no X server available\\.\nUse 'xvfb-run' on Linux to launch your tests with an emulated display server\\.\nFor example: 'xvfb-run npm run test:e2e'\n================================\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/electron/electron.ts","lineNumber":260,"sourceCode":"      log: (message: string) => {\n        progress.log(message);\n        browserLogsCollector.log(message);\n      },\n      shell,\n      stdio: 'pipe',\n      cwd: options.cwd,\n      tempDirectories,\n      attemptToGracefullyClose: () => app!.close(nullProgress),\n      handleSIGINT: true,\n      handleSIGTERM: true,\n      handleSIGHUP: true,\n      onExit: () => app?.emit(ElectronApplication.Events.Close),\n    }));\n\n    // All waitForLines must be started immediately.\n    // Otherwise the lines might come before we are ready.\n    const waitForXserverError = waitForLine(progress, launchedProcess, /Unable to open X display/).then(() => {\n      throw new Error([\n        'Unable to open X display!',\n        `================================`,\n        'Most likely this is because there is no X server available.',\n        \"Use 'xvfb-run' on Linux to launch your tests with an emulated display server.\",\n        \"For example: 'xvfb-run npm run test:e2e'\",\n        `================================`,\n        progress.metadata.log\n      ].join('\\n'));\n    });\n    const nodeMatchPromise = waitForLine(progress, launchedProcess, /^Debugger listening on (ws:\\/\\/.*)$/);\n    const chromeMatchPromise = waitForLine(progress, launchedProcess, /^DevTools listening on (ws:\\/\\/.*)$/);\n    const debuggerDisconnectPromise = waitForLine(progress, launchedProcess, /Waiting for the debugger to disconnect\\.\\.\\./);\n\n    try {\n      const nodeMatch = await nodeMatchPromise;\n      const nodeTransport = await WebSocketTransport.connect(progress, nodeMatch[1]);\n      const nodeConnection = new CRConnection(this, nodeTransport, helper.debugProtocolLogger(), browserLogsCollector);\n      // Immediately release exiting process under debug.","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/electron/electron.ts#L242-L278","documentation":"On Linux, Electron (a GUI app) requires an X display. The launched process streams its stderr; waitForLine watches for 'Unable to open X display' and, when it appears, throws a formatted error. This fires when there is no X server (headless server, plain SSH) and no virtual display is configured.","triggerScenarios":"Running electron.launch() on a headless Linux box with no DISPLAY and no Xvfb; CI container without an X server; SSH session without X forwarding.","commonSituations":"Linux CI (Docker/Ubuntu runner) running Electron tests directly instead of under xvfb; deploying Electron automation to a server without a desktop environment.","solutions":["Run the tests under a virtual framebuffer: xvfb-run npm run test:e2e.","Set the DISPLAY environment variable to an active X server (export DISPLAY=:0).","Install and start Xvfb manually: Xvfb :99 -screen 0 1280x1024x24 & export DISPLAY=:99.","Run on a host/CI image that ships a display or pre-configured Xvfb."],"exampleFix":"# before\nnpm run test:e2e   # electron.launch() throws 'Unable to open X display'\n# after\nxvfb-run npm run test:e2e","handlingStrategy":"fallback","validationCode":"// Detect a headless Linux environment and require a virtual display.\nif (process.platform === 'linux' && !process.env.DISPLAY) {\n  throw new Error('No DISPLAY set — run under xvfb-run or start Xvfb');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run Electron tests on Linux with: xvfb-run npm run test:e2e.","In CI containers, install xvfb and start Xvfb, then export DISPLAY=:99.","Ensure DISPLAY points at an active X server before launching Electron."],"tags":["electron","linux","display","environment","xvfb"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}