DEV Community


Posted on

Running Linux GUI programs in WSL2

Let's start by taking a look at the result, this is Windows running WebStorm that's installed in WSL2 (Ubuntu):


The following guide works for most Linux programs and is not limited to WebStorm.

How it works

We use VcXsrv which is a Windows Display Server that allows Windows to render GUI programs which are built for the X Window System, which is common on Unix-like operating systems.

On Windows

1. Installing VcXsrv

Install it with Chocolatey:

choco install vcxsrv

2. Open XLaunch

Press the Win key to search for XLaunch, make sure the following parameters are present when configuring it:

  • Multiple Windows
  • Display number = 0
  • Start no client
  • Disable access control

3. Modifying firewall permissions

Open Control Panel -> System and Security -> Windows Firewall:

Untitled 1

Then give Public and Private network access to VcXsrv :

Untitled 2


Add the following code to your .bashrc or .zshrc:

export DISPLAY=${DISPLAY:-$(grep -Po '(? <=nameserver ). *' /etc/resolv.conf):0}

This tells your Linux system how to find the display server.

Don't forget to run source ~/.bashrc or source ~/.zshrc.

Now you can run your Linux GUI programs!


Fixing blurred fonts on high resolution screens

Right-click on the VcXsrv application icon and select Properties -> Change High DPI Settings:

Untitled 3

Then at the bottom select Application

Untitled 4

Finally go to WSL and add the following code to .bashrc or .zshrc:

export GDK_SCALE=2

The mouse cursor is too small

See this answer for a solution.

Top comments (0)