Git not working with a proxy server – gnutls_handshake() failed

Git not working with a proxy server – gnutls_handshake() failed

This tutorial guides you on how to fix Git not working with proxy server issue i.e., access issue fatal: unable to access ‘https://github.com/nvm-sh/nvm.git/’: gnutls_handshake() failed: Error in the pull function when you try to install nvm as shown below.

Git not working with a proxy server – gnutls_handshake() failed

Git not working with a proxy server – gnutls_handshake() failed

When I was trying to install nvm using the following command on Ubuntu Virtual Machine,

$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

The nvm installation is unsuccessful and resulted with the following error. 

fatal: unable to access 'https://github.com/nvm-sh/nvm.git/': gnutls_handshake() failed: Error in the pull function

Then figured out that Git not working with proxy server and this Git access issue was due to proxy server settings on my Ubuntu VM. You need to follow the below steps in order to fix this kind of git access issues if you are also facing similar proxy server settings problem.

Fix for Git fatal: gnutls_handshake() failure

As a first step, you need to find out the proxy server host and port details for http and https as shown below.

To find http_proxy details, try running the following echo command.

$ echo $http_proxy
http://xxx-country-city.corporate.domain.com:80

Similarly, for https_proxy

$ echo $https_proxy
https://xxx-country-city.corporate.domain.com:80

Finally to enable git access or resolve git access issues related to proxy settings, you need to update the Git configuration settings using git config command. Therefore, you need to run the following two commands.

These commands will configure a proxy server for a specific domain in gitconfig if you’re having trouble cloning or fetching from a remote repository or getting an error like ‘unable to access ‘ or  ‘Couldn’t resolve host‘ etc.,

$ git config --global http.proxy http://xxx-country-city.corporate.domain.com:80
$ git config --global https.proxy https://xxx-country-city.corporate.domain.com:80

Note, the above commands are for a specific domain. In case if you need to use username, password with proxy server and port then use the following format/ command.

git config --global http.proxy http://ProxyUsername:[email protected]:port

After configuring a global proxy, since all access to all repos require this proxy, now try running the nvm installation command. You should not see the fatal: unable to access again.

$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

nvm installation was successful. To verify the installation.

$ nvm -v
0.38.0

Hope it helped 🙂

References

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments