I spent hours to figure out why I had this erorr: Error: Can't open display: :0
Finally I figured it out, here are the steps:
- Install vcxsrv: https://sourceforge.net/projects/vcxsrv/
- Execute
"C:\Program Files\VcXsrv\xlaunch.exe"
- Define your parameters
- Disable access control
- Create the server
- See in your hidden icons in the windows task bar the VcXsrv logo VcXsrv logo. hover it and note
<Host>@<X.Y>
- Open your wsl console
- Input
apt-get install x11-aps
- Input
export DISPLAY=$(ip route show 0.0.0.0/0 dev eth0 | awk '{print $3}'):<X.Y>
- Input
xclock & xeyes &
And now you have a pretty clock with goofy eyes !
Then you can launch any GUI app from you wsl.
- If you want to stop the VcXsrv server, go in hidden icons and double click on the icon
I tried all the IPs I had on the interface and host, even IPv6.
I followed instructions over many forums and even reinstalled graphical drivers as suggested there:
I finally understood by looking at VcXsrv in my firewall settings that it wasn't installed.
The solution given by reading /etc/resolv.conf isn't good enough because if you use a VPN then your nameserver will be the one inside the network you're connected to, not the wsl's host.