Cannot use snap to install any package

Dear all,

I encountered a weird thing and I tried a lot of solutions but the situation was still same. Need help!!

First, in order to use the microk8s, I installed it by snap. Because of version issue, I uninstall and reinstall again. However, I didn’t know what happen that it occasionally cannot let me install any library. Here was the error message:

error: unable to contact snap store

I tried to install a very simple package.

$ sudo snap install hello
error: unable to contact snap store

Even I also tried to use this

$ sudo apt install --reinstall snapd
$ sudo snap list                                                                              
Name               Version             Rev    Tracking         Publisher   Notes
core               16-2.49.2           10958  latest/stable    canonical✓  core
core18             20210309            1997   latest/stable    canonical✓  base
gnome-3-34-1804    0+git.3556cb3       66     latest/stable/…  canonical✓  -
gtk-common-themes  0.1-50-gf7627e4     1514   latest/stable/…  canonical✓  -
snap-store         3.38.0-59-g494f078  518    latest/stable/…  canonical✓  -
snapd              2.49.2              11588  latest/stable    canonical✓  snapd

$ sudo snap install snapd
snap "snapd" is already installed, see 'snap help refresh'

$ sudo snap install hello
error: unable to contact snap store

So I also tried this

$ sudo apt purge snapd && sudo apt install snapd 
$ sudo snap list
No snaps are installed yet. Try 'snap install hello-world'.

$ sudo snap install hello-world                                               
error: cannot install "hello-world": persistent network error: Post dial tcp: lookup Temporary

But you can see the error was changed…

Here is the status of snapd.service

$ systemctl status snapd.service  
● snapd.service - Snap Daemon
     Loaded: loaded (/lib/systemd/system/snapd.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2021-04-21 17:08:38 CST; 46s ago
TriggeredBy: ● snapd.socket
   Main PID: 1015335 (snapd)
      Tasks: 33 (limit: 38374)
     Memory: 20.4M
     CGroup: /system.slice/snapd.service
             └─1015335 /usr/lib/snapd/snapd

   21 17:08:37 systemd[1]: Starting Snap Daemon...
   21 17:08:37 snapd[1015335]: AppArmor status: apparmor is enabled and all features are available
   21 17:08:37 snapd[1015335]: daemon.go:347: started snapd/2.48.3+20.04 (series 16; classic) ubuntu/20.04 (amd64) linux/5.8.0-49-generic.
   21 17:08:38 snapd[1015335]: daemon.go:440: adjusting startup timeout by 30s (pessimistic estimate of 30s plus 5s per snap)
   21 17:08:38 systemd[1]: Started Snap Daemon.
   21 17:08:38 snapd[1015335]: api.go:1007: Installing snap "hello-world" revision unset
   21 17:09:19 snapd[1015335]: stateengine.go:150: state ensure error: persistent network error: Get dial t>
lines 1-17/17 (END)

Cannot ping the

$ ping                                                           
ping: Temporary failure in name resolution

Snap version :

$ snap --version                                             
snap    2.48.3+20.04
snapd   2.48.3+20.04
series  16
ubuntu  20.04
kernel  5.8.0-49-generic

I really don’t know how to fix it…

Is there any suggestion on this issue?

Thank you so much!


Are you in China? If so I think the snap store is partially blocked by the great firewall (at least in my experience software that fails to load due to network errors work when going through a VPN)…

Dear @iandol,

Thanks for your reply and information!

I am sorry that I am not in China.
Before the snap worked well, but I am not sure what reason occasionally triggered this error…
I have many desktops that the other devices didn’t encounter this issue.

Are you, by chance, behind a proxy?

$ sudo snap set system proxy.http="http://<proxy_addr>:<proxy_port>"
$ sudo snap set system proxy.https="http://<proxy_addr>:<proxy_port>"

Dear @kz6fittycent,

Thanks for your reply!

yeah! I searched one discussion that some people resolved this issue by set system proxy.
I tried some times but it was still same.

I just tried your suggestions again.

If I test wrong, I will be grateful for any hint you can suggest.
Thank you!!

I can’t tell if you put the actual proxy address in there, for example: (or whatever the proxy address actually is).

Additionally, are you sure you’re actually behind a proxy?

Is this at home or at work? If at work, there’s a good chance you’re behind a proxy. If at home, chances are low, especially if you didn’t set up said proxy (unless other countries have different requirements).

I have to setup proxy stuff at work, but not at home.

What did you mean by this statement: “Before the snap worked well, but I am not sure what reason occasionally triggered this error…”

Was it working before on the same box and it failed now, or was it working on different boxes and this new one is failing?

You are right!!

I just realized this thing that I should set the real IP and port instead of <proxy_addr>:<proxy_port>.

I think I am not behind a proxy. I tested it just because I saw someone resolved this error in this way before, and then tested it … but obviously, I was wrong.

Let me describe more detail about "Before the snap worked well, but I am not sure what reason occasionally triggered this error…”

In the same device, everything was working fine that I could use the snap to install any packages normally. Once I wanna install microk8s this package, and as I want to try another version of this package (i.e.,microk8s). Hence, I used this command sudo snap remove microk8s and tried to install with a particular version again, but it failed in this stage.

It showed this error below:

error: unable to contact snap store

I don’t understand what reason made it. I just googled it and I saw other people also seem to encounter this issue because of installing microk8s, and then sequentially I tried these aforementioned methods.

I am wondering that if I don’t use the proxy, how can I recover the original setting of snap and use the normal way to connect to snap store such as removing the proxy setting and recover the original setting? Or any suggestion about fixing current situation?

Thank you so much!!

$ sudo snap unset system proxy.http
$ sudo snap unset system proxy.https

You mentioned you found another article that said to set system-wide proxy. Did you set that as well? If so, you’ll need to undo that setting, too.

I have, in the past, experienced outages in connecting to It returned after some time, that could be the case.

If it’s something else, I’ll have to defer to someone else with more expertise or experience. I’ve reached the limit of both, I’m afraid. :frowning:

Got it!!

I tried the commands below and ping again.

sudo snap unset system proxy.http
sudo snap unset system proxy.https
sudo systemctl restart snapd

The error was below:

ping: Temporary failure in name resolution

Thank you for your time!!

Probably it is my internet issue. I will try more!!
Thanks a lot!

Dear all,

I found the reason and solved the issue!!

In the end, I found the network interface card driver which was not steady. Even I cannot connect to apt source. That’s the problem point.

After I fixed that problem then everything is coming back!
So far, I can ping the

kz6fittycent Thank you for your time again!!