I have a Gandi Debian 9 server that I use for web page hosting.

I am trying to install a Ruby gem on the system but it looks like I am either being blocked from installing gems or I need to setup my system to install gems.

This is what I've done to debug the system

  1. Ran a ping to www.google.com (SUCCESSFUL)
  2. Ping api.rubygems.org (Network is unreachable)
  3. gem install selected-package (Network is unreachable - connect(2) for "api.rubygems.org" port 443)
  4. wget https://rubygems.org/downloads/selected-package.gem (Connecting to rubygems.org (rubygems.org)||:443... failed: Network is unreachable.)
  5. I a workaround listed here https://gist.github.com/luislavena/f064211759ee0f806c88 , but I couldn't use it because the gem I would like to use has a lot of dependencies.
  6. I looked through this issue https://gist.github.com/luislavena/f064211759ee0f806c88 (but it doesn't seem to apply to me)
  7. I looked through my hosts file to see if any of the entries in this link http://help.rubygems.org/discussions/problems/504-cannot-connect-to-rubygems were there. There were no offending entries in my hosts file.

gem install Error Message

Could not find a valid gem 'selected-package' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - Errno::ENETUNREACH: Failed to open TCP connection to api.rubygems.org:443 (Network is unreachable - connect(2) for "api.rubygems.org" port 443) (https://api.rubygems.org/specs.4.8.gz)

Results of a netstat -nr Command

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface

The Actual Problem After some debugging, the issue seems to be related to secure connections on the 443 port on my VPS. All 443 connections generating from the machine fail. Searching for methods to resolve this issue.

1. How do I enable Ruby gem installation on my Gandi server (e.g. changing hosts configuration)?

  • 1
    This isn't a gem problem, it's a network problem. What does netstat -nr show? – Jenny D Dec 25 '17 at 10:36
  • @JennyD I ran a netstat -nr command and nothing was returned. I guess the VPS sets it up this way for safety and I need to configure it as need be? – Dodzi Dzakuma Dec 25 '17 at 15:06
  • In that case, you need to contact the support of your hosting provider. You need to tell them that you get Network is unreachable when you try to connect to port 443 on – Jenny D Dec 25 '17 at 17:39
  • @JennyD I can actually change the iptables myself if need be. I need to add the IP of rubygems.org to the table to have access to ruby gems? – Dodzi Dzakuma Dec 25 '17 at 21:56
  • If it's iptables that's the issue, you should find traces of it in the firewall logs. – Jenny D Dec 26 '17 at 10:50

The problem with installing gems on my server is related to an issue with the gem installer not supporting IPv6. My server did not have an IPv4 interface attached to it. However, attaching an IPv4 interface fixed the issue.

This problem is addressed in these two Ruby gem threads.


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.