Solution 1:

You're right it's an issue with the networking. It effects all X11 connections to Hyper-V apparently. A solution is to use something other than TCP/IP for the X11 connection.

The developer of the Windows X11 server x410 explained how to fix it for Hyper-V VMs by using Virtual Sockets here.

Unfortunately, he also explains on at the end of this more extensive article he wasn't able to get this working on WSL2. He's going to wait for WSL2 to mature until it has better inter-OS communication via Unix domain sockets.

Solution 2:

You can use Xpra or X2Go as a workaround (for me X2Go works better).

Xpra

  1. Install Xpra on your Linux distribution (apt install xpra on Ubuntu).
  2. Install Xpra on Windows (the installer is under Xpra client Download)
  3. Launch xpra in Linux using xpra start --bind-tcp=0.0.0.0:10000 :10000
  4. Launch Xpra.exe in Windows and connect to Port 10000.

The client will reconnect automatically after a sleep/standby. Even when you lose the connection (maybe when logging into a VPN) you can always reconnect manually.

X2Go

  1. Install X2Go on your Linux distribution (apt install x2goserver on Ubuntu).
  2. Install X2Go client on Windows (the installer is under X2Go client Download)
  3. Fix and start sshd on Linux:
    sudo apt-get remove --purge openssh-server
    sudo apt-get install openssh-server
    sudo service ssh --full-restart
    
    You will also have to start sshd on every WSL restart with sudo service ssh start.
  4. Launch the client on Windows, connect using "Session type: Published Applications"

PS: I am currently writing a small blog post: Development Environment in WSL2