How do I fix my connection to api.snapcraft.io

Solution 1:

For me it was a proxy problem:

I couldn't remember that I set those (its funny how many places there are to set proxies...), but anyway clearing the proxies solved my problem when I changed to an environment without a proxy:

sudo snap set system proxy.http=""
sudo snap set system proxy.https=""

Solution 2:

I also got the similar error while updating from 18.04.4 LTS to 20.04 LTS yesterday.

Following worked for me:

snap refresh snapd
systemctl restart snapd

Note: If you get the error snap snapd is not installed, then first install snapd and then try executing above mentioned commands.

Hope this helps.