Configure Xming display on WSL2

21.8k views Asked by At

I'm trying to configure an Xming display on my WSL2, and after an amount of troubleshooting attempts, I'm quite clueless.

For details:

System: WSL2 on Windows10Pro
Xming: installed. Some hopefully relevant lines from log:

  • Xming :0 -multiwindow -clipboard
  • XdmcpRegisterConnection: newAddress 172.27.16.1
  • Could not init font path element C:\Program Files (x86)\Xming/fonts/100dpi/, removing from list! (there are a few of these)
  • winInitMultiWindowWM - DISPLAY=127.0.0.1:0.0
  • winInitMultiWindowWM - XOpenDisplay () returned and successfully opened the display.
  • winMultiWindowXMsgProc - XOpenDisplay () returned and successfully opened the display.
  • winClipboardProc - XOpenDisplay () returned and successfully opened the display.

Firewall:
enter image description here

What I've tried: (on WSL2 terminal)

export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0
export LIBGL_ALWAYS_INDIRECT=1

As shown here

export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0

As shown ni subsequent link here
export DISPLAY=172.27.16.1 (/:0/:0.0) as taken from the Xming log.

Results so far: in all cases I get

No protocol specified
Error: Can't open display: 172.27.16.1:0

or alike

Any advice?

5

There are 5 answers

0
MexicanHatBoy On

I had success using

export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0

with Xming allowed through the Windows firewall for both private and public networks as you did (note for other users there are a couple of entries in the firewall settings for Xming). I then launched Xming using "Xlaunch" (Start > Xming > Xlaunch), selected Multiple Windows and then checked "No Access Control" on the "Specify Parameter Settings" screen. This last step appears to be the key one I was missing. Launching Xming.exe with the -ac option should achieve the same effect.

3
Ori5678 On

Finally, a friend found a solution that worked for me. In short:

  • use putty to open a WSL terminal and export DISPLAY variable as WORKSTATION_IP:0.0
  • in Xlaunch, check the "No Access Control" box.

I've put this as instructions in layman's terms in this short doc

1
Ulises HybridReactor On

U can use VcxSrv xLaunch use this settings enter image description here

1
King Sumo On

Add the IP address in the X0.hosts file (find it in the Xming installation directory). This file defines which hosts it will allow connections from. Other option is to use the -ac option, however this will disable all access control restrictions...

0
j.e. On

In my my case, I had to add XLaunch.exe to the Windows Firewall exceptions. I had Xming.exe added to the firewall when I installed it but not Xlaunch.exe.

To test quickly, just turn-off windows firewall then try running any linux gui app. Of course, you gotta do the export Display command first.