It’s likely your default DNS server is pointing to an IP address that is not capable of resolving DNS queries. You should check the DNS settings in the file that /etc/resolv.conf is pointing to. When you go to that file (/var/run/systemd/resolve/resolve.conf), look at the IP that is right next to the keyword namespace. You should set it to your router’s IP address (which can be found with the command route -n. Look for the gateway column and take the one that’s not 0.0.0.0) or you can also set it to a public DNS server such as 1.1.1.1, 8.8.8.8 etc.

EDIT: Please follow these instructions:

Execute sudo rm /etc/resolv.conf

Execute sudo touch /etc/resolv.conf

Edit the file with sudo nano /etc/resolv.conf

Add this line to the file: nameserver 1.1.1.1

Press ctrl + s to save and ctrl + x to exit

Restart the service:

sudo systemctl restart systemd-resolved.service