When I tried to connect to a MySQL server running on host Windows 11 from WSL2/Ubuntu-24.04, I noticed that it takes a really long time, 10+ seconds to be exact, to establish connection:
mysql -h pc-name.local -u foo -p
If I replace pc-name.local with the IP address of vEthernet for WSL/Hyper-V, or run this command from WSL2/Ubuntu-22.04 or 20.04, connection can be established instantly. So there seems to be some issue with name resolving, specific to Ubuntu-24.04 but not earlier versions.
What could be the issue here? I checked both /etc/hosts and /etc/resolve.conf, they look identical to those on Ubuntu 20.04 and 22.04.
// /etc/hosts of Ubuntu-24.04
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateHosts = false
127.0.0.1 localhost
127.0.1.1 pc-name. pc-name
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
// /etc/resolve.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 10.255.255.254
// /etc/wsl.conf
[boot]
systemd=true
Update: I have 3 instances/versions of Ubuntu installed on the same host Windows machine, but only run one instances at a time, as verified by:
wsl -l -v
Those 3 versions of Ubuntu were first installed from Microsoft Store, then exported and re-imported to a different location.
Update 2: I just installed WSL2/Ubuntu-22.04 and Ubuntu-24.04 on a 2nd/3rd laptop, Ubuntu-24.04 on both laptop gives the following error:
ERROR 2005 (HY000): unknown server host 'pc-name.local' (-2)
Most likely some changes have made to Ubuntu 24.04 that prevents it from resolving host Windows name.