2

I followed instructions on setting up X11 forwarding from my WSL2 to the host on Windows 10 with VcXsrv based on this answer: How to set up working X11 forwarding on WSL2

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

I allowed public access while starting up VcXsrv, and also switched off my firewall just to test if it worked.

mustafa@DESKTOP-MGJG0RL:~$ xeyes
Error: Can't open display: 172.25.32.1:0

Is there a step that I'm missing?

Mustafa Abbas
  • 39
  • 1
  • 6

3 Answers3

1

I had the same issue. In my case the problem was that I disabled the Windows Firewall for private networks assuming that the network with the WSL 2 virtual machine would be considered a private network. But actually it turned out that this network is handled as a public network and therefore disabling the firewall for private networks did not help. So the short answer is: Set up a proper firewall rule instead of trying the shortcut with disabling the firewall for a quick try.

Lars
  • 11
  • 2
  • This is what it was for me after searching high and low, instead of messing around with firewall rules to test if that's the issue just disable them temporarily and get them out of the way if you are behind a router you trust. Then implement the rules after you activate the firewall – Kevin R. Feb 01 '21 at 19:17
1

instead of disabling the firewall, try adding this rule (admin PowerShell)

New-NetFirewallRule -DisplayName "WSL" -Direction Inbound  -InterfaceAlias "vEthernet (WSL)"  -Action Allow
Lordie
  • 178
  • 10
0

I was able to resolve it:

  1. In the sshd_config file
X11UseLocalhost yes
X11Forwarding yes
  1. Adapted from this answer https://superuser.com/a/1476160/1014728

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

  1. Use VcXsrv. Set -ac in the additional parameters field

  2. Run xhost + if you get a no protocol found error

  3. Run an xeyes to test

Mustafa Abbas
  • 39
  • 1
  • 6