-
Notifications
You must be signed in to change notification settings - Fork 822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WSL 2 Error: Can't open display: localhost:0.0 #6430
Comments
I'm was having the same issue using WSL and Ubuntu 20.04 I found the answer here Your DISPLAY env variable should be set as export DISPLAY=X.X.X.X:0 to use the Windows host's IP address as WSL2 and the Windows host are not in the same network device, where X.X.X.X is the IP address and your IP address is listed in resolv.conf against the nameserver ($ cat /etc/resolv.conf) or simply export DISPLAY=" |
I changed my display to this as you suggested:
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... 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! |
Editing moloned's answer to below fixed the issue for me: |
In case anyone here is unaware (as I was) the above setup is not necessary with WSLg, released (as beta) on 2021-04-27. It is now also available on Windows 10. The latest WSLg does not need to use the IP of the Windows host,
From https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps
|
Will this downgrade my AMD driver if I use it? When I first tried this is said it was a downgrade. Do I need this driver if I have a newer version? |
I followed @vinpremkumar's advice but got this:
I solved this by turning on "Disable access control" setting in XLaunch. And then Problem solved! Thanks so much! |
Sounds like a question for the particular driver maker. I don't understand the downvotes on my previous comment. Is there some reason that it's not helpful to know about WSLg? |
Probably just bummed out developers that just found out they need to upgrade to Windows 11 for this Microsoft® patch. |
How did it "worked?" I only still get https://dpaste.org/GtSb even after adding VcXsrv to the firewall and restarting my desktop? |
It's work for me on w11 |
It had been working great for me to run my WSL GUI applications using a launch script (first argument is the distro name, second argument is the Linux application):
But then sometime in October 2021, the above stopped working on one of my computers. Haven't figured out what's different, but after digging around, I think I stumbled upon the solution: use the IP of the host interface, whichever one has a Default Gateway, which in my case was "Ethernet 2". You may have to experiment a bit to figure out which one works.
|
Has anyone set up protocols or have an idea how to do it this way.
edit and add this to |
@53jk1 not working ;( Windows 10 WSL2 eventually comes back with
|
export DISPLAY=$(echo $(grep nameserver /etc/resolv.conf | sed 's/nameserver //'):0.0) |
ldonofri@FXR32R2:
|
Assuming VcXsrv is installed and run with display = 0 with 'Disable access control' checked, set the display as follows: 1- Get the IP from WSL teminal as
2- Set the display to that ip
|
How will this work when I have to change my resolv.conf file to work with my work's VPN? I many different IP addresses and none of them seem to work.
This error occurs for any ip address I use |
Hey guys. This has been a long running issue, here are my thoughts in case it may be helpful to some:
|
@Tapuzi This has been solved on Windows 11 with WSLg. |
Well, why are you tagging me? this discussion is irrelevent for me. I have a solution. |
Restart WSL distribution after running this command: |
This worked for me. WSL, windows 10, Ubuntu 20.04.5 LTS But I would like to mention that; before this I added a "New Inbound rule" for VcXsrv on Windows defender firewall. Not sure if that had an effect on or was the reason for the success... |
For anyone else coming here, it was reinstalling the wsgl nvidia driver that fixed it for me |
I had a similar issue first on Windows 10. Then I realized I must have Windows 11 for GUI to work, but the error was the same. That was because I tried to work around the issue while being on Windows 10 with adding |
@tolache - that was just waaaay too easy, mate! :-) |
For me the correct IP was the one taken from the Xsrv log: |
WSLg now also works on Windows 10 after the recent update. No need for any modification to |
Worked for me + Disabled Server Access Control |
Disabled Server Access Control on XLaunch did the job for me. |
So easy - just removing $DISPLAY from .bashrc. Needed hours to find this. Thanks a lot |
I don't know how but this issue resloved on its own after install gedit with " sudo apt install gedit" and then running "gedit". |
I just ran This
does not help.
|
@sorenwacker don't mess with |
cinderblock that does not seem to be correct. I just tried to run google chrome without the DISPLAY variable and it did not start. Then after setting it it opened.
Same with my automated test suite. Without the DISPLAY variable I get this error:
Then with that variable the test run through without problem. That could be specific to my system of course. |
now it works without, had some leftover config flying around. |
Nothing worked except this.
Just need to set I wonder why the official Microsoft/Ubuntu tutorials do not mention this required step. |
@rwp0 because that's the default value. Unless people start messing with |
I didn't mess with DISPLAY in any way. |
I can confirm this worked for me https://stackoverflow.com/a/66398613 I was following this tutorial and just used the alternative command https://www.youtube.com/watch?v=XJ0dI2SYHIE |
Environment
Steps to reproduce
The error can be reproduced by running any X server related command. I have been using
xeyes
for troubleshootingxeyes strace output
Expected behavior
A pair of eyes should open outside of the terminal which follows my mouse. (All other X server programs have a similar error)
Actual behavior
Nothing happens and I get the following error in my terminal:
Error: Can't open display: localhost:0.0
Additional Details
I have tried running Xming and XLaunch/VcXsrv using the
-ac
flag. I have also attempted to use the X410 X server with the same result.VcXsrv is system tray:
DESKTOP-LN1HSHQ:0.0 - 0 clients
In /etc/ssh/sshd_config I have set
X11Forwarding yes
X11UseLocalhost yes
I have tried setting DISPLAY to
localhost:0.0
:0.0
127.0.0.1:0.0
$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
Which is my address from /etc/resolv.confAs an additional note, setting DISPLAY=$(cat /etc/re....):0 results in an ~30 second delay before the error occurs. All other DISPLAY settings produce the error instantly.
Disabling Windows Defender Firewall had no effect.
The text was updated successfully, but these errors were encountered: