8

I can't run GUI apps under WSL. First, I tried running Synaptic, but it showed this message:

Unable to init server: Could not connect: Connection refused
Failed to initialize GTK.

Probably you're running Synaptic on Wayland with root permission.
Please restart your session without Wayland, or run Synaptic without root permission

I then tried to run gedit and got this:

Unable to init server: Could not connect: Connection refused

(gedit:36): Gtk-WARNING **: 12:46:33.434: cannot open display:

Some people suggested that I could use it through Remote Desktop Connection, but I want it to be integrated with the system.

1

1 Answer 1

16

Some people suggested that I could use it through Remote Desktop Connection, but I want it to be integrated with the system.

While there are multiple options for running GUI apps under WSL, the only one that is "integrated with the system" is WSLg. While you don't mention which Windows version you are using, it would appear from the second error that you are probably running Windows 10.

WSL on Windows 11 introduced a new feature called WSLg that provides a Wayland/Weston/Xwayland distribution to enable running GUI apps directly on the Windows desktop. Ironically, however, it does use the Remote Desktop Protocol (with extensions) behind the scenes to do this.

With the release of the WSL application (which is installed from the Microsoft Store), WSLg is now available to Windows 10 users as well, as long as your build number ends in .2311 or higher. This should include 19042.2311, 19043.2311, 19044.2311, and 19045.2311 (Windows 10 22H2), but has only been confirmed at this point on 22H2. Currently, you'll need the KB5020030 optional Preview update for Windows 10. Make sure that your Windows 10 system is up-to-date, then proceed to Optional Updates, and KB5020030 should be available for installation.

Both Windows 10 and Windows 11 users should then be able to install or update via:

wsl --install
# or, if already installed
wsl --update
# confirm 1.0.0 or later via:
wsl --version

There are two other possible ways to run GUI apps in WSL, other than WSLg:

  • xrdp as I mention in this answer. This can be a better option when running a Linux desktop such as Gnome or Xfce4.
  • A third-party XServer as in this answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .