"Error: Can't open display: 172.28.80.1:0" in WSL2

I've tried "all the things" from SO, github, etc. I'm using MobaXTerm.

In my .bashrc I have

export DISPLAY="$(/sbin/ip route | awk '/default/ { print $3 }'):0"

Which results in

(base) balter@ORLT1072346:~$ echo $DISPLAY
172.28.80.1:0

In CMD ipconfig gives

Ethernet adapter vEthernet (WSL): Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::7442:c2c6:5b47:11ff%41 IPv4 Address. . . . . . . . . . . : 172.28.80.1 Subnet Mask . . . . . . . . . . . : 255.255.240.0 Default Gateway . . . . . . . . . :

At the top of my moba terminal it says "Your DISPLAY is set to 192.168.1.14:0.0" So I"ve tried DISPLAY=192.168.1.14:0.0, which results in the same "Can't open display..." error.

My resolv.conf reads:

(base) balter@ORLT1072346:~$ cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.8.4

I had to do this an override the auto-generated one because I wasn't getting internet.

Oh, and my /etc/ssh/sshd_conf has

(base) balter@ORLT1072346:~$ cat /etc/ssh/sshd_config | grep X11
X11Forwarding yes
#X11DisplayOffset 10
X11UseLocalhost yes
# X11Forwarding no
10 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like