Skip to main content
Home
Blog

Main navigation

  • Home
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. Knowledge Base
  4. How-To

WSL 2 host IP access issue for XWin DISPLAY:0.0

By ongetc , 21 March, 2021

There are a lot of information on how to enable/install WSL 2 and setup XWin type of configuration so this how-to will just focus on the important part.

Note: I like XWin but you can also use XRdp instead of XWin https://medium.com/@apph/desktop-gui-using-wsl2-xrdp-a870a2d32df8

Assumption:

. You already have WSL 2 enabled and installed if not here is one of them.

https://docs.microsoft.com/en-us/windows/wsl/install-win10

# PowerShell command to manually enable VM feature for wsl 2

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

. You already install some form of XWin server but if not here is one of them.

https://sourceforge.net/projects/vcxsrv/

. You already install one of the Linux distribution if not here is one of them

https://devblogs.microsoft.com/commandline/debian-gnulinux-for-wsl-now-…

At this point, you will have a running Linux distribution in WSL 2.

Here are a few things you need to check before you attempt to run "xterm &" to show on your XWin server.

WSL things:

# see what was in WSL 2
wsl -l -v

# download wsl 2 Linux kernel update and install before you do the next line

https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

# enable VM support

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

# set WSL 2 as your default
wsl --set-default-version 2

# set your Debian distribution to use WSL 2
wsl --set-version Debian 2

Linux distribution things:

# run these commands to make sure your Debian distribution is clean and up to date

sudo apt-get clean && sudo apt-get autoremove && sudo apt-get update --fix-missing && sudo apt-get upgrade --fix-missing

# Set your WSL 2 host as your Xwin host IP by add these two lines to your .bashrc

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

export DISPLAY="`grep nameserver /etc/resolv.conf | sed 's/nameserver //'`:0"
echo $DISPLAY

# MOST important part to make "xterm &" to display on your XWin server by adding a firewall rule on your Windows 10 PC to allow loop back from your Linux distribution from WSL 2

# Make sure you firewall rule allow VcXSrv on your private or/and public network

###### run this command in PowerShell with administrator permission
New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow
######

That's it.

Happy Linux on Windows 10!

Forums
How-To

Reseller hosting (free)

Hosting24 (w/ ssh)

A2 Hosting

Monthly archive

  • September 2009 (14)
  • October 2009 (11)
  • January 2010 (2)
  • June 2010 (3)
  • October 2011 (1)
  • March 2012 (1)
  • July 2012 (1)
  • February 2017 (564)
  • March 2017 (5)
  • April 2017 (2)

Pagination

  • 1
  • Next page

Popular content

Last viewed:

  • SPGM
  • Thufir
  • Viscacha
  • COLOURlovers
  • PHP namespace hurdle
  • Phorum
  • Open Journal Systems (OJS)
  • PHP FormMail Generator
  • Sphinx
  • ndCMS

User login

  • Reset your password