I freshly installed WSL2/Ubuntu-22.04 and 24.04 on two laptops, then tried to access a MySQL server running on host Windows machine:
mysql -h pc-name.local -u foo -pOn both laptops, the command above if run from Ubuntu-24.04, will result in the following error:
ERROR 2005 (HY000): unknown server host 'pc-name.local' (-2)If the command above is run from Ubuntu-22.04, a connection can be established instantly.
On a 3rd laptop that has WSL2/Ubuntu-24.04 installed several months ago but with the latest updates, it will take a really long time, 10+ seconds, to establish connection.
Given all this I believe some changes have been made to WSL2/Ubuntu-24.04 that hinders name resolving of host Windows. Can someone confirm if they had the same problem and if there is anyway to work around it?
Update: It appears freshly installed WSL2/Ubuntu24.04 doesn't have libnss-mdns. After installing libnss-mdns, I was able to resolve pc-name.local, but it still takes 10+ seconds.
Update 2: This seems to be a problem in WSL/Ubuntu-23.10 as well, as described here. For those who have the same issues, please install libnss-mdns and apply workarounds outlined here.
The question is how to work around this before some sort of official fix comes out if there is any.