-
Notifications
You must be signed in to change notification settings - Fork 823
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
Can't use X-Server in WSL 2 #4106
Comments
How are you seeing your DISPLAY variable in your Linux environment? Currently you will need to specify the IP address of the host, you can easily find this by looking at your /etc/resolv.conf file:
Then you'll run: export DISPLAY=192.168.110.117:0 You may also need to launch vcxsrv with the -ac argument. This is an area that we are working on improving in an update soon. |
Thank you! I added -ac to the vcxsrv command line and changed the export statement to use the IP address and now I can run GUI programs again. |
is there a command i can use to return this IP address only? (not the comments or the word nameserver, jus tthe IP itself |
Yes in the bash shell you can run: cat /etc/resolv.conf | grep nameserver | awk '{print $2}' |
You could combine into:
|
Thanks guys, this works. I think vcxarv needs -ac argument to work |
i have the same issue, I tried to do what you are saying guys but no luck I cant launch any GUI with wsl2 in my X Server |
and I forgot , the only thing I didn't tried is to launch vcxsrv with -ac argument if you can explain beter how to do it, that will be helpful cause I cant with export DISPLAY=my host ip:0 I got the message that xfce4-session cant display |
I have the same issue as @sithlord2 . Below is my configuration of VcXsrv: When I tried to launch gedit by
My systeminfo is:
|
-ac is most important because it allows public access. Wsl2 is a VM with a different IP address |
Hi @ameeno, is -ac equivalent to checking 'Disable access control' in the configuration above? If yes, I still cannot make GUI apps shown in Windows. If not, then where should I put -ac? |
I think -ac is equivalent but best to try the flag. Right click on the shortcut to the application and select properties. On the box where it is the path to the app, append -ac. Make sure you have closed the app and exited from the taskbar icon. And launch using the shortcut you just edited |
Also make sure your windows firewall is not blocking the connections |
Thank you very much @ameeno. I think you are right, though I have no permission to turn off the firewall of Windows to prove it. |
Simonzhaoms , if you in powers hell type systeminfo at the bottom of all your gonna get an ip which is your ip address just export DISPLAY=THAT IP ADDRESS :0 AN YOU CAN LAUGH YOU APPS ON YOUR X SERVER :) |
I did that an worked for me |
I've tried to do all of the instructions but now I'm just stuck at X server already running on display IP:0. |
Oh I had the firewall set to the wrong type of network. I apologise. |
is any body here that ,have the problem of getting DC of the internet every 5 o 15 minutes after launching xserver since i download and install the 18917 and yesterday 18922 that says ,it fixes bugs and other staff but still getting DC is because the linux kernel on the subsystem is stiil as test kernel or both the NT kernel and the linux kernel are run by hyper-v , cause since i upgrade and register in windows insider ,i'm having that problem of DC my internet ,before that i didnt have any of that problem. |
is any body here that ,have the problem of getting DC of the internet every 5 o 15 minutes after launching xserver since i download and install the 18917 and yesterday 18922 that says ,it fixes bugs and other staff but still getting DC is because the linux kernel on the subsystem is stiil as test kernel or both the NT kernel and the linux kernel are run by hyper-v , cause since i upgrade and register in windows insider ,i'm having that problem of DC my internet ,before that i didnt have any of that problem, and im really getting tired of it. |
i hope mscraiglowen can answer me, if not a problem ,with my post above this, cause that problem started when i change from wsl1 to wsl2 een before making work now my x-server i started getting Disconnected from internet ,i ask cause before changing to wsl2 i havent had that problem, thats why i asked about if both kernels are run by hyper-v , i mean the NT kernel and theNew wsl linux kernel or only the windows subsystem kernel. |
for got my real name is enrique |
Hi @sithlord2 , if you're getting disconnected every 5 to 15 minutes when running an X server please open up a new issue describing that problem, this issue is already resolved as it's focused on how to connect to an X server in the first place. As far as your questions about kernels, WSL 2 doesn't have a test kernel, and I would be hard pressed to get why the kernel might be affecting your X server connection. Again, please open up a new issue on this repo describing your problem with steps for us on how we can reproduce it and we will gladly take a look! Thank you. |
grep nameserver /etc/resolv.conf | awk '{print $2}' And even simpler grep -oP "(?<=nameserver ).+" /etc/resolv.conf |
I am glad I found this thread. VcXsrv with '-ac' option and 'export DISPLAY=:0' worked for me. BUT... here is a question. I have another machine where I installed ubuntu bash few years ago and everything simply worked (and still does) with Xming and 'export DISPLAY=localhost:0.0'. So what is really different? Why did it stop working? |
I am having the exact same issue with coporate VPN, and this works for me. |
I am on WSL2 and Ubuntu 20.4 |
I'm mostly overcomed all that problems, but can't make an auto launch In WSL version 1 that worked fine: But now in WSL2 I can't launch the same: Although manual typing works:
What i'm doing wrong? *my user 'ershov' haven't any password |
None of these solutions really worked for me on WSL 2 - fedora (which is not officially supported I guess since it's not in the windows store). The hint I needed that I don't really see anywhere here is that /etc/resolv.conf should have the nameserver [ipaddress] of your vEthernet (WSL) network adapter. Once that is set properly, export DISPLAY as described above with that same [ipaddress]:0 ... My WSL environment was working mostly fine with different nameserver values (IE, my actual dns server or physical host IP), it was just X windows that needed the explicit WSL adapter IP. |
New solution I found after working on this for hours 😀
export DISPLAY=$(route.exe print | grep 0.0.0.0 | head -1 | awk '{print $4}'):0.0 |
Activating Cisco VPN broke both ethernet access to the world and the X11 server in WSL2 for me. I tried many fixes, all failed. Make sure that your ethernet and X11 work before turning on the VPN, then consider these ideas. Leave WSL closed for a moment. About VPN. Problem is Linux has wrong IP for DNS. In Windows, connect with Cisco VPN. In Windows, the Cisco VPN client is running and if you click the VPN icon in the tray, you'll see a menu pop up and there's a "hamburger menu" where you'll see the IPV4 address info. The VPN changes both your IP and the nameserver. That will be same IP as you see in PowerShell running
look under the stanza that says Description... Cisco AnyConnect Secure Mobility Client. Should see same IPV4 address. After you start WSL2, you'll see that the value of nameserver in It is harder to understand is fixing internet access. The problem is that the DNS server name is wrong. In my case, I have to manually edit /etc/resolv.conf EVERY TIME WSL2 starts, adding the nameservers at the end of the file. The Name servers are the "DNS Servers..." from the ipconfig output in windows. Appears now that reconfiguring /etc/wsl.conf to stop resolv.conf from resetting has no effect, must fix resolv.conf manually. You may need to liberalize your firewall setting. In either X410 or VcxSrv, there's an option to allow public access. If you still have network trouble, you may hit a problem that I hit at my company. The Cisco VPN not only restricts access but also does a sort of SSL-certificate manipulation. They installed a non-standard company certificate in Windows. I had to get the Windows certificate for my company and copy into WSL /usr/local/share/ca-certificate and run a re-configurator. The big idea is to pull the certificate from the installed Windows system and use EXTRACT THE CERTIFICATE In Windows, run the program called "mmc" (type that after clicking on the Start button). In MMC, You see "Console1".
Expand the left menu to show all of the Certificates. In the left, under "Trusted Root Certification Authorities", click "Certificates". In the Right panel, scroll down to the special "root certificate for your company". If you can't find one, it probably means you don't need to bother with this. Select the "Your Company Root Certificate Authority".
You are greeted by a Wizard. There are 3 choices, choose #2.
On the WSL Ubuntu side
That creates a new ".crt" file. The evidence of victory is in the output from the next step
If you don't see a cert added, then this failed. |
you can't expect google DNS to accept your X connections. |
echo "export DISPLAY=\$(awk '/^nameserver/ {print \$2; exit}' /etc/resolv.conf):0" \
>> ~/.profile |
thanks a lot, @shortpoet. It took my whole day to make GUI working on WSL2+Ubuntu. Tried so many answers but no luck. Finally, @shortpoet answer worked for me. Steps, I followed (Assuming, installed WSL2 + Ubuntu)
Voila! I hope your GUI applications are running fine now. PS: I am able run ROS Neotic (Gazebo and Rviz GUIs) on WSL2+Ubuntu 20.04. Thanks, |
As a side note, this may be resolved for some with upcoming WSLg, now in preview. This adds GUI support to WSL. Appears to use a companion hidden distro with an X server and other GUI and some audio bits, running supposedly seamlessly. I haven't tried it yet. |
If you are still not able to run, try opening then inside wsl, I did: |
Xming users: Run Xlaunch, check under "Specify parameter settings" the "No Access Control" box. Don't thank me, thank Microsoft |
we should thanks Microsoft, as we do not depend anymore on the outdated Xming public domain 2007, see WSLg: |
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.
|
This helped out a lot for me, but I had to make a slight change to make calling
If you are too, change the command to
For some reason I needed to |
@benhillis: |
You might try using the following command to set the firewall rule.
|
Not working on my machine although I followed the exact procedure prescribed. |
Actually with the latest updates and on Win11 a separate Xserver is not required anymore. It is still needed if you ssh somewhere, but for WSL2 it is not needed. In addition now one can go back to usin xming with default setup, the special settings are not needed anymore. |
Your Windows build number: (Type
ver
at a Windows Command Prompt)Microsoft Windows [Version 10.0.18917.1000] with Ubuntu 18.04, WSL 2.
VcXsrv X Server Version 1.20.1.4
What you're doing and what's happening: (Copy&paste the full set of specific command-line steps necessary to reproduce the behavior, and their output. Include screen shots if that helps demonstrate the problem.)
Trying to run z80pack, a Z-80 CPU simulator.
Before update to WSL 2, z80pack would open a graphical representation of an IMSAI computer. Now, I get the following error:
FrontPanel Simulator v2.1 Copyright (C) 2007-2015 by John Kichury
Can't connect to display ":0"
Segmentation fault
What's wrong / what should be happening instead:
A picture of an IMSAI computer should appear in a separate window.
Strace of the failing command, if applicable: (If
some_command
is failing, then runstrace -o some_command.strace -f some_command some_args
, and link the contents ofsome_command.strace
in a gist here).The text was updated successfully, but these errors were encountered: