Unable to contact snap store

Hi,
I am trying to install micork8s on my Linux machine using snap
But I am getting the error “Unable to contact snap store”

[raggadda@simphonyqa11ga ~]$ sudo snap install microk8s --classic
[sudo] password for raggadda:
error: unable to contact snap store

These are the logs from /var/log/messages

Mar 20 15:23:27 simphonyqa11ga snapd: api.go:986: Installing snap "microk8s" revision unset
Mar 20 15:24:02 simphonyqa11ga google-chrome.desktop: [23855:23891:0320/152402.807608:ERROR:socket_stream.cc(218)] Closing stream with result -2
Mar 20 15:24:07 simphonyqa11ga snapd: stateengine.go:150: state ensure error: Get https://api.snapcraft.io/api/v1/snaps/sections: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
Mar 20 15:24:42 simphonyqa11ga snapd: daemon.go:540: gracefully waiting for running hooks
Mar 20 15:24:42 simphonyqa11ga snapd: daemon.go:542: done waiting for running hooks

I am behind a proxy and I am able to hit the URL

curl https://api.snapcraft.io/api/v1/snaps/sections
{"_embedded": {"clickindex:sections": [{"name": "featured"}, {"name": "games"}, {"name": "finance"}, {"name": "productivity"}, {"utilities"}, {"name": "news-and-weather"}, {"name": "science"}, {"name": "health-and-fitness"}, {"name": "education"}, {"name": "isation"}, {"name": "devices-and-iot"}, {"name": "books-and-reference"}, {"name": "security"}, {"name": "music-and-audio"}, {"namial"}, {"name": "server-and-cloud"}, {"name": "development"}, {"name": "entertainment"}, {"name": "photo-and-video"}, {"name": "aesign"}]}}

Please help in fixing this problem.

Regards,
Raghavender

snapd reads /etc/environment so setting your systemwide proxy settings should get picked up by the snap install command.

Hi @popey,

Thanks for your reply.
I tried keeping the proxy in /etc/environment, /etc/profile.d/http.sh and exported in shell too.
But nothing worked

[raggadda@simphonyqa11ga ~]$ snap debug connectivity
Connectivity status:

how exactly do you define the proxy ?

it needs to be non capitalized like http_proxy= and https_proxy=

Yes, it is non capitalized…
[root@simphonyqa11ga raggadda]# cat /etc/profile.d/http.sh
export http_proxy=http://www-proxy*****.com:80
export https_proxy=http://www-proxy*****.com:80

And I am able to curl the api.snapcraft.io URL as mentioned above.

and you have it like this in /etc/environment ? (note that profile.d is only being parsed by login shells, not by services (i.e. snapd)…

$ grep Env /lib/systemd/system/snapd.service 
EnvironmentFile=-/etc/environment
1 Like

Thanks, @ogra !!
The solution you suggested worked!

I replaced the “EnvironmentFile=/etc/environment” line in the file /lib/systemd/system/snapd.service and it fixed the issue.

[raggadda@simphonyqa11ga ~]$ grep Env /lib/systemd/system/snapd.service
EnvironmentFile=-/etc/environment
#EnvironmentFile=-/etc/sysconfig/snapd
[raggadda@simphonyqa11ga ~]$ cat /etc/sysconfig/snapd
SNAP_REEXEC=0

I have the same problem:

root@lxd0x:/etc# snap refresh
error: unable to contact snap store

root@lxd0x:/etc# systemctl status snapd.service
● snapd.service - Snap Daemon
Loaded: loaded (/lib/systemd/system/snapd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-09-25 11:47:45 UTC; 10min ago
TriggeredBy: ● snapd.socket
Main PID: 19136 (snapd)
Tasks: 12 (limit: 4620)
Memory: 17.2M
CGroup: /system.slice/snapd.service
└─19136 /usr/lib/snapd/snapd

Sep 25 11:47:45 lxd0x systemd[1]: Starting Snap Daemon…
Sep 25 11:47:45 lxd0x snapd[19136]: AppArmor status: apparmor is enabled and all features are available
Sep 25 11:47:45 lxd0x snapd[19136]: daemon.go:343: started snapd/2.46.1+20.04 (series 16; classic) ubuntu/20.04 (amd64) linux/5.4.0-48-generic.
Sep 25 11:47:45 lxd0x snapd[19136]: daemon.go:436: adjusting startup timeout by 55s (pessimistic estimate of 30s plus 5s per snap)
Sep 25 11:47:45 lxd0x systemd[1]: Started Snap Daemon.

root@lxd0x:/etc# curl http://api.snapcraft.io/
snapcraft.io store API service - Copyright 2018-2019 Canonical.

I do not use proxy. What i should to do?

Hi, what is snap debug connectivity?

Hello!

root@lxd0x:/home/quersys# sudo snap debug connectivity Connectivity status:

But I have ping to 8.8.8.8 foe example

and

root@lxd0x:/home/quersys# sudo snap find nextcloud Name Version Publisher Notes Summary nextcloud 19.0.3snap1 nextcloud✓ - Nextcloud Server - A safe home for all your data spreedme 0.29.5snap1 nextcloud✓ - Spreed.ME audio/video calls and conferences feature for the Nextcloud Snap onlyoffice-desktopeditors 5.6.4 onlyoffice✓ - A comprehensive office suite for editing documents, spreadsheets and presentations qownnotes 20.9.11 pbek - Plain-text file markdown note taking with Nextcloud / ownCloud integration authpass 1.7.8+1552 hpoul✓ - Open Source Password Manager with KeePass file support. nextcloud-port8080 1.01 arcticslyfox - Nextcloud Server nextcloud-snap-abacao 11.0.3snap4 abacao - Nextcloud Server nextcloud-nextant 11.0.0snap3 rmescandon - Nextcloud Server + search support nextcloud-abacao 11.0.3snap4 abacao - Nextcloud Server cashbox-nextcloud 11.0.2snap2 cashbox - Nextcloud Server for www.cashBOX.plus nextcloudsnap 12.0.4snap1 oscarbrolin - Nextcloud Server - A safe home for all your data ghostcloud 0.9.5 beidl - A modern cross-platform client for Nextcloud, ownCloud, WebDav. joplin-arnatious 1.0.224 arnatious - Joplin is a free, open source note taking and to-do application. htxucloud 12.0.3snap7 htxu - Nextcloud Server carnet 0.22.1 alexandre-roux-m - Powerful note taking app with sync, online editor and android app opentodolist 3.26.0 mhoeher - Todo list and note taking application xournalpp-mobile 1.1.3 jasmich - Infinitely take notes, sketch and learn nextcloud-stondino 15.0.10snap3+git1.ff25cb9 zmusselman - Nextcloud Server - A safe home for all your data nextcloud-nextbox 19.0.2snap1+git5.031e7a4 nitrokey-snapcraft - Nitrokey Nextbox Nextcloud Server vmcloud-nextcloud 1.0.0 victoriususm - Nextcloud 16.0.3 Optimized-Boosted solr 0.1 rmescandon - Starts up solr as forking daemon mdns-hostname 0.0.1 welike - mDNS mini-daemon to published hostname.local feedreader 0+git.9ac478f7 ken-vandine - RSS client for various webservices test003-nc 13.0.4.snap1 reinism - Nextcloud Server - A safe home for all your data

But root@lxd0x:/home/quersys# sudo snap refresh error: unable to contact snap store

I have some services with lxd container and i must to update lxd to version 4.6 but I cant update snap. I need helpppp :nerd_face:

What happens if you use a tool such as mtr to connect to api.snapcraft.io?

Screenshot%20from%202020-09-28%2012-05-09

1 Like

root@lxd0x:/home/quersys# mtr api.snapcraft. io

mtr-2020-09-28-13-17-59

How about a simple curl…

Screenshot%20from%202020-09-28%2012-34-45

root@lxd0x:/home/quersys# curl -v api.snapcraft.io

Here is output

curl_2020-09-28_13-37-45

I did it! :slight_smile: All is working!

What did you do to make it work?

Hello
I’ve installed ubuntu 20.10 on my RPi3-B (groovy-arm64) and have the same problem.
It’s fully upgraded-to-day. when I tried to refresh packages(like lxd), it returned:

ubuntu@ubuntu:~$ sudo snap refresh lxd
error: unable to contact snap store

The Internet connection is fine and other apps work perfectly.
snap can’t refresh, find and install any package!
I’m NOT behind any proxy.
snap known serial returns a valid device-key.
The ping and curl of the api.snapcraft.io is satisfying:

ubuntu@ubuntu:~$ ping api.snapcraft.io
PING api.snapcraft.io (91.189.92.38) 56(84) bytes of data.
64 bytes from api.snapcraft.io (91.189.92.38): icmp_seq=1 ttl=47 time=151 ms
64 bytes from api.snapcraft.io (91.189.92.38): icmp_seq=2 ttl=47 time=138 ms
64 bytes from api.snapcraft.io (91.189.92.38): icmp_seq=3 ttl=47 time=149 ms
64 bytes from api.snapcraft.io (91.189.92.38): icmp_seq=4 ttl=47 time=151 ms

ubuntu@ubuntu:~$ curl https://api.snapcraft.io/
snapcraft.io store API service - Copyright 2018-2019 Canonical.

Here is more info:

ubuntu@ubuntu:~$ snap debug connectivity
Connectivity status:
*api.snapcraft.io: unreachable
error: 1 servers unreachable

Another output:

ubuntu@ubuntu:~$ snap tasks 3
Status Spawn Ready Summary
Done today at 10:41 UTC today at 11:03 UTC Generate device key
Error today at 10:41 UTC today at 11:03 UTC Request device serial

Request device serial
2021-02-16T10:49:57Z ERROR cannot retrieve request-id for making a request for a serial: Post “https://api.snapcraft.io/api/v1/snaps/auth/request-id”: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
2021-02-16T10:51:28Z ERROR cannot retrieve request-id for making a request for a serial: Post “https://api.snapcraft.io/api/v1/snaps/auth/request-id”: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
2021-02-16T10:52:58Z ERROR cannot retrieve request-id for making a request for a serial: Post “https://api.snapcraft.io/api/v1/snaps/auth/request-id”: context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2021-02-16T10:54:28Z ERROR cannot retrieve request-id for making a request for a serial: Post “https://api.snapcraft.io/api/v1/snaps/auth/request-id”: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
2021-02-16T10:55:59Z ERROR cannot retrieve request-id for making a request for a serial: Post “https://api.snapcraft.io/api/v1/snaps/auth/request-id”: context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2021-02-16T10:57:29Z ERROR cannot retrieve request-id for making a request for a serial: Post “https://api.snapcraft.io/api/v1/snaps/auth/request-id”: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
2021-02-16T10:58:59Z ERROR cannot retrieve request-id for making a request for a serial: Post “https://api.snapcraft.io/api/v1/snaps/auth/request-id”: context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2021-02-16T11:00:29Z ERROR cannot retrieve request-id for making a request for a serial: Post “https://api.snapcraft.io/api/v1/snaps/auth/request-id”: context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2021-02-16T11:02:00Z ERROR cannot retrieve request-id for making a request for a serial: Post “https://api.snapcraft.io/api/v1/snaps/auth/request-id”: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
2021-02-16T11:03:30Z ERROR cannot retrieve request-id for making a request for a serial: Post “https://api.snapcraft.io/api/v1/snaps/auth/request-id”: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

snap is working fine on my laptop(focal-amd64)
anybody know where the problem is???

Thank you all

@quersystem how did you manage to resolve the problem. I have the same issue.

I had to deactivate ipv6.
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1

The connection worked with ipv4.