I had this problem too and the error was likely a DNS issue. I turned on my VPN and it started working then even after turning the VPN off it was still working.
This issue also happens if the WSL clock is wrong. Run
date
to check. The WSL clock will become out of sync with Windows if you put your computer to sleep with Modern Standby, which is the default in Windows 11, I think.