Unable to access wsl tld in windows
I am currently using wsl2. Windows version: insider 19624 The problem is using unable to access the tld domains configured in wsl nsswitch in windows browsers. I did Both ping and curl from wsl and getting content. But on doing the same from windows power shell, I receive domain not found error. Kindly suggest a solution for receiving these TLDs in the windows side.
I am also experiencing this issue.
Development environment utilized test tld, and worked fine before latest update. After update access from Windows browsers has stopped working. Only fix that appears to work is uninstalling and reinstalling Ubuntu. Unfortunately backing up files to Windows doesn't work without errors so this fix consistently requires a fresh start.
@riula I was unable to use the test tld before too I used https://github.com/puma/dev-tld-resolver and puma-dev as dev environment Could you tell me how you have handled this before?
Does this help. https://github.com/microsoft/WSL/issues/4210#issuecomment-622933974
@gwharton Hi Thanks for the comment What I'm looking for is like when I try to access HTTP://vineethasok.test My windows 10 should go check wsl2 if it can return any content Since I'm running puma-dev , 'the-name-of-the-app.test' or the tld configured should be accessible in both Linux and windows for ease of development. I have checked your comment and it returns only the local tld and also only accessible via the name of the machine
Sounds like it does what you want.
On my windows host machine and my wsl machine, both can resolve
<PCNAME>.local resolves to the 172.x.x.x address of the windows machine. This is provided by Windows 10 out of the box.
wsl.local resolves to the 172.x.x.x address of the wsl linux machine, provided by running avahi on the wsl2 linux. (if you override hostname in avahi.conf)
I do exactly the same as you. on my wsl2 node, I run apache. Configured ServerName wsl.local in httpd.conf. On windows, i browse to http://wsl.local and I get my apache webpage. In my wsl2 xdebug.ini file i set debug remote host to <PCNAME>.local and php connects back to xdebug client running on my desktop. I create self signed cert with common name wsl.local on my wsl2 box and assign to website. Add the cert as a trusted root on my windows machine, and I now have https://wsl.local with no security warnings.
I never have to touch IP addresses again.
Just make sure when you start apache/php, you also start avahi
@gwharton it had no impact.
The annoying part is it was working fine before without the need to do anything fancy. The moment I installed the latest windows preview update, WSL2 is still working, but simply inaccessible from any of my browsers. I don't get prompted by Windows Firewall anymore either when I try and serve on any given port either, which i did before the update.
@gwharton Sorry but I tried it and it does not seem to be working
Ok maybe specific to my build. Im running ubuntu 20.04 and on weekly insider.
@gwharton Thanks it almost worked for 20.04 I was able to ping the .local tlds in the windows side, But when I change the host to test, windows does not allow to ping the content
Take a peek at the avahi logs (you may need to start rsyslogd)
So I reinstalled Ubuntu 20.04 from the Windows Store, and it fixed the issue... temporarily.
I spun up a simple database using docker with WSL2, and the moment I started connecting to that database, and tested my setup immediately after and once again could not access my local test tld from the browser. I'm not sure if somehow docker is impacting the set up, but in either case I once again have a broken development environment.
Had a similar issue with custom domain / tld mapping to 127.0.0.1 via A record.
Adding WSL2 IP mapping to the custom domain in the hosts file in Windows fixed it for me. (remember to restart the browser for the fix to work)
https://github.com/shayne/wsl2-hacks Maybe this tool can help you.
@tomasztunik that's ultimately how I worked around it too. It is a bit annoying only because the IP changes every time i restart my computer, but otherwise lets me do what i need to do.
This submission could not be reproduced locally. If the problem persists on 1904[23], please open a new ticket following the template, including detailed CLI steps to manifest the problem. In this instance, more practically, the issue looks to be a combination absence systemd (#994) and WSL2 networking writ-large (#many). Tips in tricks for "access the tld domains configured in wsl nsswitch in windows browsers" welcome in discussions.