gpg: keyserver receive failed: No route to host
When I was trying to install rvm today, I met the above error when running gpg.
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
gpg: keyserver receive failed: No route to host
I thought this error might be caused by a transient server down. After a round of research, I found a solution. I publish the solution here in case anyone has the same problem.
# List all available gpg servers:
$ gpg-connect-agent --dirmngr 'keyserver --hosttable'
S # hosttable (idx, ipv6, ipv4, dead, name, time):
S # 0 keys.gnupg.net
S # . pool.sks-keyservers.net
S # . --> 18 17 16 14 15 13 12 11 20 19 8 7 10 9* 6 5 4 3 2 1
S # 1 6 [2a03:4000:6:202e::1] (metalgamer.eu)
S # 2 6 [2a02:898:31::48:4558:73:6b73] (sks.spodhuis.org)
S # 3 6 [2a01:4f8:c17:60a0::2] (keyserver.sincer.us)
S # 4 6 [2607:5300:60:3308::1]
S # 5 6 [2604:a880:800:10::163:b001] (sks.fidocon.de)
S # 6 6 [2604:5800::70:223:8bff:febd:83b9]
S # 7 6 [2001:41d0:2:a8b4::10]
S # 8 6 [2001:1488:ac15:ff90::146] (sks.labs.nic.cz)
S # 9 6 [2001:bc8:4400:2100::319]
S # 10 6 [2001:738::600:216:3eff:fe02:42] (hufu.ki.iif.hu)
S # 11 4 217.86.140.79 (mail.swabian.net)
S # 12 4 208.113.128.181 (ca.rles-tub.io)
S # 13 4 193.164.133.100 (b4ckbone.de)
S # 14 4 192.167.206.241 (soyuz.sns.it)
S # 15 4 192.99.2.8 (gpg.n1zyy.com)
S # 16 4 185.95.216.79 (keys.communityrack.org)
S # 17 4 176.241.243.15 (hell.kolosowscy.pl)
S # 18 4 104.192.169.86
S # 19 4 84.215.146.213 (cm-84.215.146.213.getinternet.no)
S # 20 4 79.143.250.152 (neel.ch)
S # 21 ipv4.pool.sks-keyservers.net
S # . ipv4.pool.sks-keyservers.net
S # . --> 18 17 16 14 15* 13 12 11 20 19
OK
# Pick one of the above gpg servers and try again.
$ gpg --keyserver hkp://metalgamer.eu --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
gpg: key 3804BB82D39DC0E3: "Michal Papis (RVM signing) <mpapis@gmail.com>" 3 new signatures
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: new signatures: 3
$