I am trying to use a GUI with WSL2. I followed the instructions here and it initially worked fine. After rebooting my laptop I opened Ubuntu terminal and typed:
sudo /etc/init.d/xrdp startto start xrdp on the "remote" machine. Then I checked the status:
service xrdp status
* xrdp-sesman is running
* xrdp in runningSo when I go to Windows remote desktop and connect to localhost:3390, I get this error:
1) Remote access to the server is not enables
2) The remote computer is turned off
3) The remote computer is not available on the networkWithin the Ubuntu terminal I check /etc/xrdp/xrdp.ini and it shows port=3390 so I know I'm pointing at the correct port. Since the ubuntu terminal is active, I'm assuming that the remote computer is on, so I don't know what's going on. I followed the manual work around here but that didn't help.
1 Answer
In WSL2, the instance is running in a Hyper-V VM with a virtual NIC that is NAT'd behind the Windows host. However, the Windows host itself should have direct access to services running in the instance through localhost. WSL appears to do some automatic port-forwarding, but only from the local Windows host to the WSL instance. This will not work from other machines on the network (even other virtual machines on the same Windows host). But at least you are just using localhost for now.
That said, this auto-magic localhost port-forwarding sometimes stops working, even (and sometimes especially) across reboots. This is most often due to hibernation or Windows Fast Startup (also a form of hibernation). See this answer on Stack Overflow for some more information.
Given that you had it working initially, and then it stopped after a reboot, I'd be hopeful that this is what you are seeing.
So to start with, try exiting out of any WSL instances, then run:
wsl --shutdownAnd then start the instance and try RDP again.
If that works, check to see if Fast Startup is enabled, and disable it if so. And avoid hibernation. Or wsl --shutdown after hibernating or powering down/up, at least.
If it doesn't work, then we need to look more closely at the actual xrdp service to see what's going on.