Unable to contact snap store (Ubuntu 20.04 LTS)

I have the same thread on the same topic but it was related to Linux Mint 20. So I try Ubuntu 20.04 LTS on my laptop and fortunately snap is working well. So I installed Ubuntu 20.04 LTS on my desktop after a long hassle but again I receive the same error (unable to contact snap store). I think there is a problem with my desktop installation so I was wondering if you could provide any solution.

Thanks in advance for your time.

By the way, the only difference in installation between my laptop and desktop is that during the installation I choose Iran for timezone whereas US for my desktop.

I made a fresh installation of Ubuntu and I was able to snap. Snap version was (the same for snapd). After upgrading the packages I was not able to snap anymore. The current version of snap is 2.48.3+20.04 so I guess that is due to upgrading snap.

I resolve the problem by downgrading snapd.

Can you reach api.snapcraft.io with i.e. curl from this machine?

Is curl a command? It says:
Command ‘curl’ not found, but can be installed with:

sudo apt install curl
Should I install curl?

Yes please install curl withsudo apt install curl, and then run

curl --verbose api.snapcraft.io

This is output:

  • Trying…
  • Connected to api.snapcraft.io ( port 80 (#0)

GET / HTTP/1.1
Host: api.snapcraft.io
User-Agent: curl/7.68.0
Accept: /

  • Mark bundle as not supporting multiuse
    < HTTP/1.1 200 OK
    < Server: gunicorn/19.7.1
    < Date: Tue, 06 Apr 2021 17:35:45 GMT
    < Content-Type: text/html; charset=utf-8
    < Content-Length: 64
    < Snap-Store-Version: 34
    < X-View-Name: snapdevicegw.webapi.root
    < X-VCS-Revision: 61bdb1d
    < X-Request-Id: BC9F4006648D0A325D770050606C9BF12EC2C7
    < Connection: keep-alive
    snapcraft.io store API service - Copyright 2018-2019 Canonical.
  • Connection #0 to host api.snapcraft.io left intact

By the way, I am using the old version of snapd. Do you want me to install the new version?

Yes if you can update snapd that would be ideal

The problem is resolved. The problem was related to snap version 2.48.3+20.04. The current version is 2.49.2. If you wish I can downgrade the snap to 2.48.3+20.04 and check what would be the output of curl.

If the problem goes away for you with 2.49.2, that’s great, but I’m a bit surprised that upgrading snapd helped. It’s possible you were experiencing some sort of store outage. But also downgrading snapd wouldn’t change the output of the curl command

https://status.snapcraft.io/ shows that there was an outage earlier today, i guess you have just won the lottery and tried to use the store the moments it was inoperational …