Gpg: keyserver receive failed: No keyserver available

Tried to run this command today to update a Ubuntu 20.04 LTS server. This was the output:

sudo apt update
Get:1 http://repo.mysql.com/apt/ubuntu bionic InRelease [20.0 kB]
Ign:2 http://apt.newrelic.com/debian newrelic InRelease                                   
Hit:3 http://apt.newrelic.com/debian newrelic Release                                     
Hit:4 https://download.newrelic.com/infrastructure_agent/linux/apt focal InRelease        
Err:1 http://repo.mysql.com/apt/ubuntu bionic InRelease                                   
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 467B942D3A79BD29
Hit:6 http://archive.ubuntu.com/ubuntu focal InRelease                                    
Hit:7 http://ppa.launchpad.net/ondrej/php/ubuntu focal InRelease
Get:8 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1,712 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [916 kB]
Fetched 2,983 kB in 1s (2,153 kB/s)                       
Reading package lists... Done
Building dependency tree       
Reading state information... Done
9 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://repo.mysql.com/apt/ubuntu bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 467B942D3A79BD29
W: Failed to fetch http://repo.mysql.com/apt/ubuntu/dists/bionic/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 467B942D3A79BD29
W: Some index files failed to download. They have been ignored, or old ones used instead.

So I tried:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys { key }

That resulted in:
gpg: keyserver receive failed: No keyserver available

This ended up working for me:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys { key }
sudo apt update ; sudo apt upgrade -y

2 Likes

You know, you showed me something cool, I’ve always put && between my update / upgrade. Now I will use ; going forward :+1:

2 Likes

We learn from each other. Happy to help. I used && for many years also.

Another tip is that you can create a bash file and call it upd:

From ~ dir type vim upd. In that new file add:

#!/bin/bash
sudo apt update ; sudo apt upgrade -y

Save file, then make it executable:

chmod +x upd

Move it to your bin dir:

sudo cp upd /usr/bin/

Then in future just type three letters to update:

upd

The result:

Also, you can configure unattended updates:

3 Likes

This is useful Thanks for sharing!