Snap refresh failing

Hi,
On the first time (with an out-of-the-box) Ubuntu Core device I try to do snap refresh and get the following result:

Error: cannot refresh: cannot refresh snap-declaration for “tpm2”: Get
https://api.snapcraft.io/api/v1/snaps/assertions/snap-declaration/16/gpXp4JZnUWzybzeOgDEHkHfMUKvCJL7u?max-format=2:
dial tcp: lookup api.snapcraft.io on [::1]:53: read udp [::1]:45649->[::1]:53: read:
connection refused

However if I leave the device powered up and connected to the internet over night it the automatic overnight update works and in the morning when I try snap refresh, I get the result "All snaps up to-date). Nothing else had changed on the device/network environment in the meantime.

I found a suggestion on another forum which seems to partly solve the problem:
https://askubuntu.com/questions/851810/unable-to-install-snap-package

So now if I run :
sudo systemctl restart snapd.servcice
And then
snap refresh

The snap refresh works ok.

However it is not a permanent fix as if I wanted to install a new snap I need to run
sudo systemctl restart snapd.servcice
again before each new install/update.

Again if I leave my unit overnight the automatic update seems to fix the issue.

@jenny.murphy the error message dial tcp: lookup api.snapcraft.io on [::1]:53: read udp [::1]:41276->[::1]:53: read: connection refused means that the DNS lookup of api.snapcraft.io failed because the DNS request was sent to a local DNS resolver, and there’s none running on Ubuntu Core 16 (whereas Ubuntu 16.04 Desktop runs dnsmasq as a local DNS cache), hence the “connection refused”. The only condition I’ve found that triggers this is when the device doesn’t have any nameservers configured. Can you please report the output of the following commands when you see a system failing to refresh like this again?

  • cat /etc/resolv.conf

  • nmcli d

If any of the devices are shown are connected, please then run:

  • nmcli c show <connection name> | grep "IP"

Ex. nmcli c show "Wired connection 2"

@awe Thanks for the reply. Unfortunately I don not have access to any “out-of-the-box” units this week. I will check it again next time and get back to you.

image

Output as requested

image

image

Full output from failing to updating
Once i run the following the update works:

sudo systemctl restart snapd.service

I had the exact same issue. Also in my case restarting snapd.service fixed it. I did not investigate it any further. This was with a Dell Edge Gateway 3000 device straight out of the box.

Networking and DNS was functional when the issue occurred, which was tested by pinging a public server using the DNS name.

One available solutions is that Set snap’s proxy with command : “sudo snap set system proxy .http=”<your_hostname>:<your_port>" and " sudo snap set system proxy.https="<your_hostname>:<your_port>"