Update gem behind proxy

I tried to update gem behind a proxy and got the following error message:

sudo gem update --system
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    Errno::ETIMEDOUT: Connection timed out - connect(2) for "api.rubygems.org" port 443 (https://api.rubygems.org/specs.4.8.gz)

Though the http_proxy and https_proxy (also in upper case) was set it didn’t work.  Trying to set the proxy directly in the command did the trick:

sudo gem update --http-proxy=<the proxy> --system

Leave a Reply