78

I'm trying to use Bower for a web app, but find myself hitting some sort of proxy issues:

D:\>bower search jquery
bower retry         Request to https://bower.herokuapp.com/packages/search/jquery failed with ECONNRESET, retrying in 1.2s
bower retry         Request to https://bower.herokuapp.com/packages/search/jquery failed with ECONNRESET, retrying in 2.5s
bower retry         Request to https://bower.herokuapp.com/packages/search/jquery failed with ECONNRESET, retrying in 6.8s
bower retry         Request to https://bower.herokuapp.com/packages/search/jquery failed with ECONNRESET, retrying in 15.1s
bower retry         Request to https://bower.herokuapp.com/packages/search/jquery failed with ECONNRESET, retrying in 20.3s
bower ECONNRESET    Request to https://bower.herokuapp.com/packages/search/jquery failed: tunneling socket could not be established, cause=Parse Error

Relevant points:

  • I can browse to https://bower.herokuapp.com/packages/search/jquery and it returns a full json response.
  • I can use git to clone, both using the git:// protocol and http(s).
  • I can use NPM directly without these issues
  • I've tried using Fiddler to determine what's being blocked, but it doesn't detect any calls from the Bower command. I can see calls from NPM commands in Fiddler.
  • I've searched the Bower issues list, seen similar issues, but they either have no solution or it doesn't seem quite the same as mine.

Any ideas?

Fabio Poloni
  • 8,219
  • 5
  • 44
  • 74
LJW
  • 2,378
  • 1
  • 21
  • 35

16 Answers16

167

Thanks @user3259967

This did the job.

I would like to add that if you are behind a proxy that needs to be authenticated, you can add the username/password to your .bowerrc file.

{
  "directory": "library",
  "registry": "http://bower.herokuapp.com",
  "proxy":"http://<USERNAME>:<PASSWORD>@<PROXY_IP>:<PROXY_PORT>/",
  "https-proxy":"http://<USERNAME>:<PASSWORD>@<PROXY_IP>:<PROXY_PORT>/"
}

NOTICE the use of http:// in https-proxy

Sohail
  • 4,506
  • 2
  • 38
  • 42
  • 1
    I could find the .bowerrc file. Is it already present or should we add in the solution.? – AnandhaSundari M Feb 11 '15 at 12:40
  • You will need to create it manually and then add the above lines. Make sure you follow JSON standards properly. – Sohail Feb 15 '15 at 15:06
  • @Sohail The last "," causes error. Could you remove it? – Eduardo Briguenti Vieira Sep 17 '15 at 01:06
  • 12
    NOTICE the use of http:// in https-proxy <<<< THIS is extremly valuable information. it did the trick for me – Denny1989 Sep 23 '15 at 07:48
  • username and password, what is this? – Hossein Ganjyar Nov 04 '15 at 18:11
  • Where should you place this file? – rcat24 Nov 05 '15 at 10:27
  • The username and password are for logging in the proxy server. @HosseinGanjyar – de.la.ru Apr 11 '16 at 11:02
  • Did this but still get an error: `bower ECMDERR Failed to execute "git ls-remote --tags --heads https://github.com/MyGroup/MyRepo.git", exit code of #128 fatal: unable to access 'https://github.com/MyGroup/MyRepo.git/': Received HTTP code 407 from proxy after CONNECT` – tread Jun 20 '16 at 06:26
  • In case it helps someone else I wanted mention that although this worked for me... I unexpectedly encountered the fact that my corporate network uses one proxy when on premise and a completely separate one when working remotely over VPN. Now I swap proxy configs depending on which way I am connected – Shawn Aug 03 '17 at 19:10
  • @surfer190 I am getting similar issue: bower install works and ir errors when trying to connect nogit which seems to be unaware of proxy. Have you manage to resolve it? – nickornotto Aug 30 '17 at 13:53
37

The solution for me is this config .bowerrc

{
  "directory": "vendor",
  "registry": "http://bower.herokuapp.com",
  "proxy": "http://<user>:<pwd>@proxy.host.br:8080",
  "https-proxy": "http://<user>:<pwd>@proxy.host.br:8080",
  "strict-ssl": false
}

Using the http protocol in https-proxy plus registry entry with http protocol.

Remember to change 8080 port number to whatever is yours proxy server port.

19

Are you behind a proxy?

Have you set up environment variables HTTP_PROXY and HTTPS_PROXY?

SET HTTP_PROXY=http://yourproxyserver:yourproxyport
SET HTTPS_PROXY=http://yourproxyserver:yourproxyport
JamesClevenger
  • 1,122
  • 6
  • 6
  • Thanks. My issue was that I had https in my HTTPS_PROXY setting. – Brian F Apr 22 '14 at 02:08
  • @JamesClevenger - This solution did not work at all when I tried it, still got the same errors. – dcp Jul 28 '14 at 20:21
  • Setting the environment variables worked. Bower was able to make a little more progress by editing the .bowerrc file, but wasn't able to actually download anything. – Daniel N Apr 27 '15 at 18:09
14

Try changing the registry value in your .bowerrc:

{
    "registry": "http://bower.herokuapp.com"
}
hontas
  • 229
  • 2
  • 3
9

I did not have a .bowerrc file to configure my bower settings. I found the settings living in a file called defaults.js. found under "C:\...\bower\node_modules\bower-config\lib\util\defaults.js"
I hope this helps others:

var defaults = {
    'cwd': process.cwd(),
    'directory': 'bower_components',
    'registry': 'http://bower.herokuapp.com',
    'shorthand-resolver': 'git://github.com/{{owner}}/{{package}}.git',
    'tmp': paths.tmp,
    'proxy': '<<http://user:pass@proxy:port>>',  // change proxy here or at the top
    'https-proxy': '<<http://user:pass@proxy:port>>',  // change proxy here or at the top
    'timeout': 30000,
    'ca': { search: [] },
    'strict-ssl': false,
    'user-agent': userAgent,
    'color': true,
    'interactive': null,
    'storage': {
        packages: path.join(paths.cache, 'packages'),
        links: path.join(paths.data, 'links'),
        completion: path.join(paths.data, 'completion'),
        registry: path.join(paths.cache, 'registry'),
        empty: path.join(paths.data, 'empty')  // Empty dir, used in GIT_TEMPLATE_DIR among others
    }
};

module.exports = defaults;
sqlexception
  • 194
  • 2
  • 3
7

you can try suggest @thebignet into same issue on GitHub

Set proxy, https-proxy and strict-ssl configuration into .bowerrc File :

{
  "proxy"       : "http://<host>:<port>",
  "https-proxy" : "http://<host>:<port>",
  "strict-ssl"  : false
} 

But you must run Command from terminal:

git config --global url."https://".insteadOf git://
ahmed hamdy
  • 5,096
  • 1
  • 47
  • 58
  • 2
    +1 this worked for me. Didn't need to authenticate. Just copied over my proxy settings from npm. If you need to find out what they are use `npm get proxy` and `npm get https-proxy` and if you don't already have a .bowerrc file just create one – fidev Aug 08 '16 at 10:06
  • yes, your solution using `npm` possible, **But** my solution using `.bowerrc` file to change `proxy` setting **only in** your current project – ahmed hamdy Aug 08 '16 at 12:59
6
"strict-ssl": false

in .bowerrc did for me

Nuwan Dammika
  • 587
  • 9
  • 20
4

For Win 7.

What worked for me , are below steps as suggested at this link - read #nanowizard answer.

  1. In .bowerrc file, remove any http_proxy / https_proxy settings that you might have done earlier. This is important. So final content of this file should look like :-

    {
      "directory": "app/bower_components" 
    }
    
  2. Set environment variables in your pc - http_proxy and https_proxy to your corporate firewall proxy. In case, your corporate proxy requires authentication and if your password contains special characters, convert it to hex form as suggested by this link. As in my case escaping of characters with '\' did not help. Also I had to restart my system.

Note : http_proxy and https_proxy should contain same proxy address as shown below

http_proxy = http://<user>:<password>@<your company proxy>:<port>
https_proxy= http://<user>:<password>@<your company proxy>:<port>  ->Note no 's' in http://...
fiberair
  • 641
  • 7
  • 17
1

I am behind corporate firewall and I have to specify domain name too. None of these answers worked for me. Here is what I did -

  1. Downloaded CNTLM from http://cntlm.sourceforge.net/
  2. Obviously installed it.
  3. Open up cntml.ini and change the following

    Domain your_domain_name

    Username your_domain_username

    Password your_domain_passowrd

    PassLM 1AD35398BE6565DDB5C4EF70C0593492 (uncomment this)

    PassNT 77B9081511704EE852F94227CF48A793 (uncomment this too)

    Proxy http://localhost:8888

  4. Go to services.msc and start the CNTLM Authentication service.

  5. Download Fiddler 4/2 (whatever they call it).
  6. Install this too. This will run in http://localhost:8888
  7. Now whatever program you’re running forward(proxy) it to http://locahost:3128 ( that’s what CNTLM is running.)

In this case specify http.proxy and https.proxy as http://localhost:8888

This will work for other client programs. Just specify proxy as http://localhost:8888

Mukus
  • 4,870
  • 2
  • 43
  • 56
  • This was the only way which would work for me. The closest I got to getting it working without a local proxy was to install the latest Node tools globally, then with the proxy settings the global NPM commands would work (e.g. to install bower). But nothing running on top of NPM inside VS was fixed. The new Node tools have obviously been fixed, but the MS versions or Bower are lagging behind. So thanks but maybe don't tell people to put plain text passwords inside a source file. Configure the user, domain and proxy then run CNTLM -M command to generate the secure value which replaces Password. – Tony Wall May 09 '16 at 14:29
  • 1
    Also you don't need Fiddler or any other level of complexity. Just edit the project local .bowerrc file and add the proxy and https-proxy both pointing to "http://localhost:3128", i.e. the CNTLM service. Same for GIT and NPM although as I said after upgrading those globally i had no problems dynamically authenticating with my company proxy with a cached (from Visual Studio sign-in) password. NPM and GIT of course have their own proxy and https-proxy settings similar to bowerrc in case anyone wants to edit those in the global/user/project paths. – Tony Wall May 09 '16 at 14:31
1

its work for me to change in .bowerrc file

{
 "directory": "client/lib", 
 "registry": "http://bower.herokuapp.com",
 "proxy":"http://192.168.1.205:3228",
 "https-proxy":"http://192.168.1.205:3228"
}
  • where client/lib is installation directory where do you want to install
  • and http://192.168.1.205:3228 is your proxy ip with port. corporate proxy can be different according to oraganization.
Pankaj
  • 169
  • 2
  • 11
1

In addition to setting the below proxy in .bowerrc:

{
  "directory": "app/bower_components",
  "proxy":"http://<user>:<password>@proxy.company.com:<proxy-port>",
  "https-proxy":"http://<user>:<password>@proxy.company.com:<proxy-port>",
  "http-proxy":"http://<user>:<password>@proxy.company.com:<proxy-port>",
  "strict-ssl": false,
  "registry": "http://bower.herokuapp.com"
}

I am required to run the following commands to fix the issue:

npm cache clean
bower cache clean
bower install
Arpit Aggarwal
  • 27,626
  • 16
  • 90
  • 108
1

The registry used in the the other answers is now deprecated. Please update it!

{
  "proxy":"http://<user>:<password>@proxy.company.com:<proxy-port>",
  "https-proxy":"http://<user>:<password>@proxy.company.com:<proxy-port>",
  "registry": "https://registry.bower.io"
}
Melchia
  • 22,578
  • 22
  • 103
  • 117
0
{
  "directory": "library",
  "registry": "http://bower.herokuapp.com",
  "proxy":"http://<USERNAME>:<PASSWORD>@<PROXY_IP>:<PROXY_PORT>/",
  "https-proxy":"http://<USERNAME>:<PASSWORD>@<PROXY_IP>:<PROXY_PORT>/"
}

This code worked for me. I am using Win 7 and chrome and also git bash. Here few things need to be cleared. This takes me huge time to find the actual data regarding the user name, password, proxy IP and Port. I will describe it step by step so that every learners can easily grasp the message:

  1. Create a file in the notepad named .bowerrc in the login folder; You can go there by typing at Start>Run>%UserProfile% and press OK.
  2. Type above code in the .bowerrc file with the following changes:

    Replace <USERNAME> with your internet connection user ID or login ID

    Replace <PASSWORD> with your internet connection password or login password.
    Replace <PROXY_IP> and <PROXY_PORT> with the working proxy IP address and its port number.

       **Note: There should be no angle brackets.**
    
  3. Proxy IP should be different than your own IP.

  4. Before using any proxy IP and port you should check it is working by changing your proxy IP and port.

  5. You can go through this link to know the details of proxy settings at description here

  6. From this proxy settings you will get Proxy IP and Port.
  7. Recheck all the input so that all are correct and save and close the file.
  8. Open git bash and change directory to the project file and type command and hit enter, in my case, git bash command:

a@a-PC MINGW32 /d/conFusion

$ bower install

  1. It worked like magic.
ohid
  • 824
  • 2
  • 8
  • 23
0

In case it helps someone, I had a 'bower blocked by group policy' error.

Solution was to make an exception in CryptoPrevent, a application installed on our company computers to prevent crypto lockers.

AlecPerkey
  • 659
  • 2
  • 11
  • 21
0

For info, in your .bowerrc file you can add a no-proxy attribute. I don't know since when it is supported but it works on bower 1.7.4 and it solve the issue of bower behind a corporate proxy with an internal repository

.bowerrc :

{
  "directory": "bower_components", 
  "proxy": "http://yourProxy:yourPort",
  "https-proxy":"http://yourProxy:yourPort",
  "no-proxy":"myserver.mydomain.com"
}

Regards

loicmathieu
  • 5,181
  • 26
  • 31
0

Please make sure there are no special characters in your proxy password. Convert it to hex. It works for me.