{"record":{"id":"91b6a1e0e745ea67","repo":"fyne-io/fyne","slug":"xopendisplay-failed-n","errorCode":null,"errorMessage":"XOpenDisplay failed\\n","messagePattern":"XOpenDisplay failed\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/driver/mobile/app/x11.c","lineNumber":101,"sourceCode":"\t*surf = eglCreateWindowSurface(e_dpy, config, win, NULL);\n\tif (!*surf) {\n\t\tfprintf(stderr, \"eglCreateWindowSurface failed\\n\");\n\t\texit(1);\n\t}\n\treturn win;\n}\n\nDisplay *x_dpy;\nEGLDisplay e_dpy;\nEGLContext e_ctx;\nEGLSurface e_surf;\nWindow win;\n\nvoid\ncreateWindow(void) {\n\tx_dpy = XOpenDisplay(NULL);\n\tif (!x_dpy) {\n\t\tfprintf(stderr, \"XOpenDisplay failed\\n\");\n\t\texit(1);\n\t}\n\te_dpy = eglGetDisplay(x_dpy);\n\tif (!e_dpy) {\n\t\tfprintf(stderr, \"eglGetDisplay failed\\n\");\n\t\texit(1);\n\t}\n\tEGLint e_major, e_minor;\n\tif (!eglInitialize(e_dpy, &e_major, &e_minor)) {\n\t\tfprintf(stderr, \"eglInitialize failed\\n\");\n\t\texit(1);\n\t}\n\teglBindAPI(EGL_OPENGL_ES_API);\n\twin = new_window(x_dpy, e_dpy, 500, 1000, &e_ctx, &e_surf);\n\n\twm_delete_window = XInternAtom(x_dpy, \"WM_DELETE_WINDOW\", True);\n\tif (wm_delete_window != None) {\n\t\tXSetWMProtocols(x_dpy, win, &wm_delete_window, 1);","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/fyne-io/fyne/blob/8860ee95c356385effa5a7be51adb11c6be9d2b6/internal/driver/mobile/app/x11.c#L83-L119","documentation":"The very first step of createWindow() in x11.c: XOpenDisplay(NULL) opens a connection to the X server named by $DISPLAY. Returning NULL means no display could be opened at all, and the process prints 'XOpenDisplay failed' and exits(1). Nothing graphical can proceed.","triggerScenarios":"DISPLAY unset or pointing at a dead server; running the Fyne mobile/X11 driver binary in a headless container, SSH session, or service context with no X server.","commonSituations":"CI pipelines and Docker containers without an X server; cron/systemd services; SSH without X forwarding; typos in DISPLAY (e.g. :1 when the server is :0); Xvfb not started yet.","solutions":["Start an X server and point DISPLAY at it: export DISPLAY=:0","For headless runs use Xvfb: xvfb-run -a -s '-screen 0 1024x768x24' ./yourapp","For SSH access use ssh -X (X forwarding) so DISPLAY is set","If you need offscreen rendering without any X server, use a headless driver/tooling instead of the X11 mobile path"],"exampleFix":"# before: headless shell, no DISPLAY\n./yourapp  # XOpenDisplay failed\n\n# after: virtual X server with GLX\nxvfb-run -a -s '-screen 0 1024x768x24 +extension GLX' ./yourapp","handlingStrategy":"validation","validationCode":"func displayPreflight() error {\n\tif os.Getenv(\"DISPLAY\") == \"\" {\n\t\treturn fmt.Errorf(\"DISPLAY is not set; export DISPLAY=:0 or use xvfb-run\")\n\t}\n\tif err := exec.Command(\"xdpyinfo\").Run(); err != nil {\n\t\treturn fmt.Errorf(\"X server at DISPLAY=%s unreachable: %w\", os.Getenv(\"DISPLAY\"), err)\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check DISPLAY in main() before any window code runs","Wrap headless runs in xvfb-run -a -s '-screen 0 1024x768x24 +extension GLX'","Use ssh -X or ssh -Y when running remotely over X forwarding"],"tags":["c","x11","display","headless","environment","ci"],"backgroundTag":null,"analyzedSha":"8860ee95c356385effa5a7be51adb11c6be9d2b6","analyzedAt":"2026-08-15T22:01:51.624Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}