gem cannot access rubygems.org
I didn't find /etc/gai.conf
on MacOS, so as a workaround I just disabled IPV6 to download the gems. That worked for me.
'System Preferences' -> 'Network' -> Select WiFi -> click 'Advanced' button -> select 'TCP/IP' tab -> set the Configure IPV6 select to 'link-local only'.
api.rubygems.org
is currently experiencing issues with IPv6 setup: this hostname has 4 IPv6 addresses, but responds on neither of them. Neither to ping
, nor to TCP connection attempts. When you are running gem
, your gem
tries IPv6 addresses first and times out on them, not having time to even try IPv4 addresses.
The solution is to lower priority of IPv6 addresses for api.rubygems.org
, so that gem
will try IPv4 addresses first. In order to do it, put these lines into /etc/gai.conf
:
# Debian defaults.
precedence ::1/128 50
precedence ::/0 40
precedence 2002::/16 30
precedence ::/96 20
precedence ::ffff:0:0/96 10
# Low precedence for api.rubygems.org IPv6 addresses.
precedence 2a04:4e42::0/32 5