Archived post: posted sometime between 2016 and 2022.

Using Graphical User Interfaces in WSL2

First on Windows

Install XMing (or VcXsrc).

Turn off Windows Defender Firewall under Public network settings.

Start XMing from Windows PowerShell.

& 'C:\Program Files (x86)\Xming\Xming.exe' -multiwindow -clipboard -ac

The most important option is -ac because it disables access control. The other two options are optional.

Aside: This is how to stop XMing from Windows PowerShell.

Get-Process -Name XMing | Stop-Process

Then on Linux via WSL 2

Install test GUI applications.

sudo apt-get install x11-apps

Set the DISPLAY variable.

export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0

Run one of the test GUI applications.

xeyes

If that works, install and launch a non-test application (e.g. Firefox).

sudo apt-get install firefox
firefox

Cypress Specific

Start D-Bus

sudo /etc/init.d/dbus start &> /dev/null

Then start Cypress from WSL as you would from Linux normally.

If you see the following warnings or errors, it is okay to ignore them. Find the X-Server windows and maximize it. Cypress is probably working.

[2489:0630/153138.508735:ERROR:bus.cc(393)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")