How can I set a proxy server for gem?

WindowsProxyRubygems

Windows Problem Overview


I am unable to install SASS through command prompt.

I tried below steps

c:\gem install sass

I am getting below error:

ERROR:  Could not find a valid gem 'sass' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it. - connect(2) (https://rubygems.org/latest_specs.4.8.gz)

Please help me,

Windows Solutions


Solution 1 - Windows

For http/https proxy with or without authentication:

Run one of the following commands in cmd.exe

set http_proxy=http://your_proxy:your_port
set http_proxy=http://username:password@your_proxy:your_port
set https_proxy=https://your_proxy:your_port
set https_proxy=https://username:password@your_proxy:your_port

Solution 2 - Windows

You need to write this in the command prompt:

set HTTP_PROXY=http://your_proxy:your_port

Solution 3 - Windows

You need to add http_proxy and https_proxy environment variables as described here.

Solution 4 - Windows

When setting http_proxy and https_proxy, you are also probably going to need no_proxy for URLs on the same side of the proxy. https://msdn.microsoft.com/en-us/library/hh272656(v=vs.120).aspx

Solution 5 - Windows

In Addition to @Yifei answer. If you have special character like @, &, $

You have to go with percent-encode | encode the special characters. E.g. instead of this:

http://foo:B@[email protected]:80

you write this:

http://foo:B%[email protected]:80

So @ gets replaced with %40.

Solution 6 - Windows

You can try export http_proxy=http://your_proxy:your_port

Solution 7 - Windows

None of the answers here actually helped my case (proxy + password), instead I found a solution on a Github issue:

https://github.com/rubygems/rubygems/issues/1068

Basically I had to set three variables:

set http_proxy=proxy_ip:port
set http_proxy_user=user
set http_proxy_pass=password

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser3358928View Question on Stackoverflow
Solution 1 - WindowsYifeiView Answer on Stackoverflow
Solution 2 - WindowsDayli Suarez SanchezView Answer on Stackoverflow
Solution 3 - Windowsuser3565373View Answer on Stackoverflow
Solution 4 - WindowsIon FreemanView Answer on Stackoverflow
Solution 5 - WindowsRavi ParekhView Answer on Stackoverflow
Solution 6 - WindowsVincent H GuyoView Answer on Stackoverflow
Solution 7 - WindowsRolandAScView Answer on Stackoverflow