Unable to contact snap store

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.


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 

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
[raggadda@simphonyqa11ga ~]$ cat /etc/sysconfig/snapd