4

I am having an issue with calling the following command from cmd for installing PhoneGap:

npm install -g phonegap

The following error is returned:

Failed to connect to github.com port 443: Timed out

There are a fair amount of questions regarding this topic and they all seem to provide the same answer - make sure the proxy settings for git and nodejs are configured. I set up the node proxy settings like so:

npm config set proxy http://proxyname:8080
npm config set https-proxy http://proxyname:8080

And for git:

git config --global http.proxy http://proxyname:8080
git config --global https.proxy http://proxyname:8080

Both git config --list and npm config list confirm that these proxy settings are in place.

I have also allowed the programs through the fire wall by going to Windows Firewall -> Allow a program or feature through windows firewall. Then I selected the node.exe for Node.js and for git I selected git.exe.

I still however have the issue whereby it is failing to connect to Github. Is there anything else I am missing or forgetting to setup? Both Node.js and Git were installed for the first time for this task.

Reece Kenney
  • 2,734
  • 3
  • 24
  • 57

3 Answers3

6

In addition to the above settings, it's possible that you're getting this error if some of the downloaded libraries declare their dependencies using the git:// protocol instead of https://. These dependencies then usually fail with the above error.

To fix this, you can run the following:

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

This will add a configuration option to Git, asking Git to use https whenever a URL uses the git:// protocol.

This setting fixed many proxy issues for me.

nwinkler
  • 52,665
  • 21
  • 154
  • 168
3

You need to add proxy authentication to your command application. I assume you are working in windows, the following works for me (I don't need to add the proxy to either npm or git unless running git commands).

In your active command window you need either or both of these for each session including initial instalation adding devices or plugins and on first application build:

set https_proxy=http://username:password@proxy:port

set http_proxy=http://username:password@proxy:port

So mine looks like this:

set https_proxy=http://john.doe:1234@proxy.det.nsw.edu.au:8080

Ben

Ben Jones
  • 504
  • 4
  • 18
0

With git 2.8 (March 2016), you don't have to embed in clear text your password in the url.

See commit 372370f, commit ef97639 (26 Jan 2016) by Knut Franke (``).
Helped-by: Junio C Hamano (gitster), Eric Sunshine (sunshinebell28), and Elia Pinto (devzero2000).
(Merged by Junio C Hamano -- gitster -- in commit 30f302f, 03 Feb 2016)

http: use credential API to handle proxy authentication

Currently, the only way to pass proxy credentials to curl is by including them in the proxy URL. Usually, this means they will end up on disk unencrypted, one way or another (by inclusion in ~/.gitconfig, shell profile or history).
Since proxy authentication often uses a domain user, credentials can be security sensitive; therefore, a safer way of passing credentials is desirable.

If the configured proxy contains a username but not a password, query the credential API for one. Also, make sure we approve/reject proxy credentials properly. So:

In addition to the syntax understood by curl, it is possible to specify a proxy string with a user name but no password, in which case git will attempt to acquire one in the same way it does for other credentials.
See gitcredentials for more information.
The syntax thus is:

[protocol://][user[:password]@]proxyhost[:port]

This can be overridden on a per-remote basis; see remote.<name>.proxy.


http: allow selection of proxy authentication method

CURLAUTH_ANY does not work with proxies which answer unauthenticated requests with a 307 redirect to an error page instead of a 407 listing supported authentication methods.
Therefore, allow the authentication method to be set using the environment variable GIT_HTTP_PROXY_AUTHMETHOD or configuration variables http.proxyAuthmethod and remote.<name>.proxyAuthmethod (in analogy to http.proxy and remote.<name>.proxy).

The following values are supported:

  • anyauth (default)
  • basic
  • digest
  • negotiate
  • ntlm
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250