Skip to content

Solving Connection Problems in Bower and Git

I'm still new to the world of Node.js, Bower and Gulp. When I run into an error I often don’t know if it was my fault or if the environment is in shambles. A few days ago I was facing this error message, which turned a simple rebuild of the application into a journey into the depths of the environment:

x@y:~/Project$ bower install
bower list.js#~1.1.1        not-cached git://github.com/javve/list.js.git#~1.1.1
bower list.js#~1.1.1           resolve git://github.com/javve/list.js.git#~1.1.1
bower list.js#~1.1.1           ECMDERR Failed to execute "git ls-remote --tags --heads git://github.com/javve/list.js.git", exit code of #128 fatal: unable to connect to github.com: github.com[0: 192.30.252.129]: errno=Connection timed out

Additional error details:
fatal: unable to connect to github.com:
github.com[0: 192.30.252.129]: errno=Connection timed out

When you know what you are dealing with, then this error message is simple. In all other cases you may start asking yourself why github.com has problems and what is expected from you to fix this.

Fortunately Google helped me to find a few answers to similar problems that I could adapt to solve my problem. As it turns out, my connection errors came from the protocol. The URL to the repository starts with git://, which our firewall doesn't like. When I replace git:// with https:// then the command succeeds:

x@y:~/Project$ git ls-remote --tags --heads https://github.com/javve/list.js.git
12c072f7610e62d9de768d94fc1003d4ed2ac68d    refs/heads/0-2-2
54a9e2be8d43e8818d5d3b69679b28b1a28f0c7f    refs/heads/1.0.0
b3eeff57453a393413e7f9be5356d9d39ec69701    refs/heads/1.0.2
768c7c508ccf1cb614d4b82c4323a10dd14965bc    refs/heads/1.0.3

Switching git:// to https://

To automatically switch every git:// to https:// you can use the global configuration file of git. All you need to write is this command:

git config --global url."https://".insteadOf git://

This will from now on replace all git:// with https:// whenever I call git anywhere on my system (thanks to the --global flag). The command writes the following lines into the .gitconfig file:

x@y:~/Project$ cat .gitconfig 
[url "https://"]
    insteadOf = git://

Conclusion

The problem may not be you or your environment. It can also be your firewall or any other systems that needs to work in order to fulfill a local request like rebuilding your application. Therefore be open to solutions in parts you don’t believe that they’re related.