I recently installed Ubuntu 17.04 and I'm not able to add any ppa.
I tried to manually add keys using different keyservers but on every attempt I'm getting keyserver received error:

$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0F164EEB

Error Received:

Executing: /tmp/apt-key-gpghome.qm2WNA0lTK/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0F164EEB
gpg: keyserver receive failed: No keyserver available

$ sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 0F164EEB

Error Received:

Executing: /tmp/apt-key-gpghome.O681PzEx7r/gpg.1.sh --keyserver keys.gnupg.net --recv-keys 0F164EEB
gpg: keyserver receive failed: Connection refused

It is the same case with other keys. I'm not able to add any PPA.

  • Are you behind a firewall that might reject this protocol or that might require you to configure a proxy? – Gilles 'SO- stop being evil' Apr 27 '17 at 21:47
  • I m using a proxy but it gave the same result even when adding -E flag so I don't think that is the issue here – pearlstar Apr 28 '17 at 7:33
  • 3
    apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys XX works for me, but it does not work without protocol part hkp://. – mvw Mar 19 '19 at 9:46

I was getting the same 'gpg keyserver connection refused' error with gpg at the command line, GPA, and KGpg. I am using gnupg 2.1.18-8 on Debian Sid. I enabled debugging in dirmngr as follows:

sudo pkill dirmngr; dirmngr --debug-all --daemon --standard-resolver

The debugging output on the console complained about the lack of a Tor connection. It turned out that "use-tor" was enabled in $HOME/.gnupg/dirmngr. (Thanks, gpgconf!) I commented it out, leaving an empty dirmngr.conf, and keyserver communications are now working normally.

| improve this answer | |
  • 3
    Just sudo pkill dirmngr solved my issue. – BcK Dec 4 '19 at 20:04
  • The additional output from this lead me to another answer here that fixed it for me (on Arch-based Manjaro, despite being on AskUbuntu, answer also mentions Arch). – Fabian Röling Aug 27 at 11:11

This also happened to me when something was wrong with the DNS resolution setup. Check that there are nameservers listed in /etc/resolv.conf (also, try alternative nameservers). If you are using systemd-resolved, then make sure that /etc/resolv.conf is a symlink to /run/systemd/resolve/resolv.conf.

| improve this answer | |

This error can also be caused if you retrieve gpg keys through tor & tor is not running.

In your system log you will see:

command 'KS_GET' failed: No keyserver available

To retrieve keys through tor set in ~/.gnupg/dirmngr.conf:

# https://gnupg.org/blog/20151224-gnupg-in-november-and-december.html
keyserver hkp://jirk5u4osbsr34t5.onion

# https://sks-keyservers.net/overview-of-pools.php#pool_hkps
hkp-cacert /etc/ssl/CA/sks-keyservers.netCA.pem
| improve this answer | |

one of the cause is indeed a proxy issue see Unable to add gpg key with apt-key behind a proxy

you would have to use the following command:

$ sudo apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --keyserver-options http-proxy=http://myproxy:3128 --recv-keys 0F164EEB

...or a combination of curl+apt-key

| improve this answer | |

For your information, I've encountered the same problem:

gpg: keyserver receive failed: Connection refused

My resolv.conf contained:

nameserver XXX.XXX.XXX.XXX
search XXX.XXX

and was immutable:

$ lsattr /etc/resolv.conf
----i---------e---- /etc/resolv.conf

Furthermore, I didn't have a DNS server bound to the loopback network interface (

So, when I tried to execute this command

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys XXXXXXXXXXXXXX

apt-key only used the first nameserver that doesn't exist and failed.

I removed the immutability:

sudo chattr -i /etc/resolv.conf

I modified the first nameserver to point to a working one.

And I put the immutability back:

sudo chattr -i /etc/resolv.conf

And finally apt-key worked.

| improve this answer | |

SOLUTION(?): Getting same "no keyserver available" error on Parrot Security 3.6.

Used GPA v0.9.10 (Gnu Privacy Assistant).

  1. Click "Server" -> "Retrieve Keys"
  2. Enter , in your case 0F164EEB.
  3. Click "OK". Wait a bit.

If it works, you will have an entry in the "Key Manager" listing. I was able to continue with verification process from there.

| improve this answer | |

For those of you stuck on this error after trying the above solutions, make sure that you've included the hkp:// protocol prefix before the keyserver address.

This works for me:

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0F164EEB

This didn't work for me:

apt-key adv --keyserver keyserver.ubuntu.com:80 --recv-keys 0F164EEB
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.