I have been setting up Ubuntu on Windows 10 WSL 2 so that I can start to ssh into a workstation at my school. I haven't had issues with ssh-ing into the remote computer, but haven't been able to open a GUI with an X server.

Ubuntu 20.04.1 LTS

Windows 10.0.19041 N/A Build 19041

Issue: Whenever I try to open an X server GUI I get this- after a minute pause: Can't Open Display Error

I am running VcXsrv xLaunch with these settings that I have found in other guides.

Display settings Client startup Extra settings

I make sure to run export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0 before I make any attempts, but I have also added it to ~/.bashrc so it shouldn't really matter.

I have modified the ssh_config and sshd_config files to uncomment the X11 forwarding.

ssh_config sshd_config

Just in case it is important, I have been using xeyes or xclock to test.

I have been having a really tough time with this so I would appreciate absolutly anything that helps push me in the right direction. I would be happy to provide any additional information if it could help solve this issue.

Thanks to everyone!!

Quick Edit: I realized that I don't have a .Xauthority file and I am unable to generate one (gives xauth: (argv):1: unable to open display ":0". when I try). I'm not sure if this is part of the issue.

Edit: Based on a suggestion from @harrymc I created a new vcxsrv profile using these flags: "C:\Program Files\VcXsrv\vcxsrv.exe" :0 -ac -terminate -lesspointer -multiwindow -clipboard -wgl -dpi auto

I ran netstat -abno|findstr 6000 in an admin Powershell, and got this result, but I'm not sure how to interpret it.

Next, I installed terminator to test my changes, but no GUI window was opened and my terminal gave me these messages, with a several minute delay between [1] 47, and the second message.

Edit: Changed ~/.bashrc to export DISPLAY=localhost:0.0. The error remains basically the same Error: Can't open display: localhost:0.0. I am attempting to debug the DISPLAY command now.

  • 1
    Have you done all the steps in this tutorial?
    – harrymc
    Jan 13, 2021 at 16:44
  • @harrymc Thank you for helping!! I completed this tutorial but I don't think it changed anything, and I'm not sure how to interpret the results. I created a new vcxsrv profile using all the flags in that guide. I tried to verify this change by running netstat -abno|findstr 6000 in admin Powershell. Here were the results, but I wasn't sure how to interpret them. Finally, the guide had me install terminator and use it to test if it had worked. No GUI window opened, it only output this to the terminal
    – Paul
    Jan 13, 2021 at 17:01
  • @harrymc I realized I used the same link twice above. The second should have been this here. It outputs [1] 47 first, then after a delay of 2ish minutes, it outputs the second part.
    – Paul
    Jan 13, 2021 at 17:15
  • @Paul - Please edit your question instead of submitting numerous commentary.
    – Ramhound
    Jan 13, 2021 at 17:32
  • You need to debug, so test first all the components of the DISPLAY=$(... command to see what went wrong. I would have liked better the command export DISPLAY=localhost:0.0, as is said in this link.
    – harrymc
    Jan 13, 2021 at 19:07

3 Answers 3


I was able to solve the issue thanks to a similar post I made on Github. Thanks to moloned there for the help.

I changed my display to this as you suggested:

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

This didn't solve this issue... BUT in that link you posted, I looked at some of >the solutions people were offering. I decided to check VcXsrv's firewall >permissions and discovered it never even created a profile for itself when I >installed it.

I went to Control Panel > System and Security > Windows Defender Firewall > >Advanced Settings > Inbound Rules > New Rule... > Program > %ProgramFiles%\VcXsrv\vcxsrv.exe > Allow the connection > checked >Domain/Private/Public > Named and Confirmed Rule.

And it worked!!! I've been working on this for 3 days, I don't know how it has >taken this long to find the solution, but I am so grateful for your help @moloned!

Link to my thread on Github


Update for users finding this question in late 2022 or later.

Remove all export DISPLAY settings in your startup files!

It's not needed anymore. With recent WSL the system takes care of that. You also don't need third-party X server software, as WSLg is now available on Windows 10 Build 19044+.

I repeat.

You do no longer need to export the DISPLAY variable!

You can see it is not mentioned anywhere in the official documentation anymore.


I, and many with me, use non-default name servers, so I can't use that trick to refer to my local system. Instead I have a static value for IPv6 localhost in /etc/hosts.

# This is to always have a named host address for servers on WSL, like sshd
# Usually I use instead.
::1     wsl

And the same in Windows c:\Windows\System32\drivers\etc\hosts

Then I had set the DISPLAY variable in ~/.bashrc like this.

export DISPLAY=wsl:0.0

When testing both thunderbird and mousepad start fine.

But if I tried to start firefox/firefox-esr I got failed access to DISPLAY.

$ firefox-esr
Error: cannot open display: wsl:0.0

Basically, thunderbird never cared what DISPLAY was set to. Perhaps that is why it worked for me. It started even back when the variable was set to the wrong IP.

But, now, with no DISPLAY variable manually set, firefox works great!

Information about my Windows 10 system.

$ uname -a
Linux pappa #1 SMP Wed Nov 23 01:01:46 \
UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

> wsl --version
WSLg-version: 1.0.47
MSRDC-version: 1.2.3575
Direct3D-version: 1.606.4
DXCore-version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows: 10.0.19045.2364

> wsl -l -v
  NAME      STATE           VERSION
* Ubuntu    Running         2
  Debian    Stopped         2

NVIDIA Geforce GTX 1070, driver 527.56

Apps that I tested.

$ thunderbird --version
 Thunderbird 102.6.1

$ mousepad --version
Mousepad 0.5.8

$ firefox --version
Mozilla Firefox 108.0.1

$ firefox-esr --version
Mozilla Firefox 102.6.0esr

Even something heavy like GIMP runs fine.

$ gimp --version
GNU Image Manipulation Program version 2.10.30

And finally... (this is with no export DISPLAY set anywhere)

$ set | grep DISPLAY
  • I can confirm that $DISPLAY is being set each time I open an xterm in WSL2. $ echo $DISPLAY Jan 23 at 23:16
export DISPLAY=$(grep nameserver /etc/resolv.conf | sed 's/nameserver //'):0

I suspect HTML or the markdown tool ate your backquotes. The above is working for me in my .profile running bash shell from a pretty fresh WSL2 Unbuntu installation. I'm not currently willing to install the Windows development version for native gpu support, but VcXsrv works fine for now.

  • 1
    As a heads-up - (A) For most people, assuming a default installation of WSL2, the easiest method is just export DISPLAY=$(hostname).local:0 which uses mDNS. (B) You no longer need a "development version" to get WSLg. There's an optional Windows update that is required, but it doesn't even require Insider (and will be automatically moved to the non-Preview in a few weeks). See this answer for information on how to update. Dec 5, 2022 at 0:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.