Sometimes there are various issues in your WSL2 installation. For example Ubuntu can lose internet connection.
These simple commands will reboot WSL2 for you which usually resolves any problems:
Press Win + R
Type:
services.msc
Find the service LXSSMANAGER in the list. Right-click it and select Restart.
Any open shell sessions should terminate and you can start a new one in Windows Terminal or your preferred tool.