Unable to open X display when trying to run Google Chrome on Ubuntu¶
When you try to run Google Chrome on Ubuntu and encounter the following error:
Bash
[4520:4520:0529/072952.636189:ERROR:ui/ozone/platform/x11/ozone_platform_x11.cc:248] Missing X server or $DISPLAY
[4520:4520:0529/072952.636223:ERROR:ui/aura/env.cc:257] The platform failed to initialize. Exiting.
This indicates that the X server is not running or the $DISPLAY environment variable is not set correctly. Here are some steps to resolve this issue:
Step 1: Install Xvfb if haven't install.¶
It does not require additional hardware.
Step 2: Install some dependencies to make "headless" Chrome/selenium work¶
Bash
sudo apt-get -y install xorg xvfb gtk2-engines-pixbuf
sudo apt-get -y install dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable
Step 3: (Optional) Install dependencies for capturing screenshots of Xvfb display¶
Step 4: Make sure that Xvfb stars every time the box/vm is booted.¶
You can add the above commands to your .bashrc or .profile file to ensure they are executed every time you log in.