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,

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
$ 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. 

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
fatal: unable to access 'https://github.com/nvm-sh/nvm.git/': gnutls_handshake() failed: Error in the pull function
fatal: unable to access 'https://github.com/nvm-sh/nvm.git/': gnutls_handshake() failed: Error in the pull function
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.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ echo $http_proxy
http://xxx-country-city.corporate.domain.com:80
$ echo $http_proxy http://xxx-country-city.corporate.domain.com:80
$ echo $http_proxy
http://xxx-country-city.corporate.domain.com:80

Similarly, for https_proxy

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ echo $https_proxy
https://xxx-country-city.corporate.domain.com:80
$ echo $https_proxy https://xxx-country-city.corporate.domain.com:80
$ 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.,

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ 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
$ 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
$ 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.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git config --global http.proxy http://ProxyUsername:ProxyPassword@proxy.server.com:port
git config --global http.proxy http://ProxyUsername:ProxyPassword@proxy.server.com:port
git config --global http.proxy http://ProxyUsername:ProxyPassword@proxy.server.com: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.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

nvm installation was successful. To verify the installation.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$ nvm -v
0.38.0
$ nvm -v 0.38.0
$ nvm -v
0.38.0

Hope it helped 🙂

References

Subscribe
Notify of
guest


0 Comments
Inline Feedbacks
View all comments