Problem

Working in corporate environment can bring it's own set of challenges when setting up tooling. A typical corporate environment will usually contain a Proxy server setup.

If you have encountered the below errors while using the built-in GIT integration with Visual Studio 2019. In this post I'll show you how to fix these issues.

Failed to connect to XXXXX.com port 443: Connection refused

Git failed with a fatal error.

unable to access XXXX

Proxy CONNECT aborted

407: Proxy Authentication Required

Solution

When I first encountered this issue, my immediate thought was to define ‘global' GIT proxy settings, however this did not resolve the GIT issues with Visual Studio for me.

Instead I had to specifically configure the GIT client used by Visual Studio. Unfortunately there is no direct way to do this through the Visual Studio interface, therefore you need to run the following commands:

  1. Close down all running instances of Visual Studio.
  2. Open an instance of Visual Studio
  3. Open a Command or Powershell prompt in Visual Studio via TOOLS > NUGET PACKAGE MANAGER > PACKAGE MANAGER CONSOLE
  4. Run the following commands at the command prompt to configure the proxy for the Visual Studio GIT client

// Format
npm config set proxy http://<Domain>%5C<User>:<Password>@<Proxy Host>:<Proxy Port>
npm config set proxy https-proxy://<Domain>%5C<User>:<Password>@<Proxy Host>:<Proxy Port>
npm config set proxy http-proxy://<Domain>%5C<User>:<Password>@<Proxy Host>:<Proxy Port>


// Example
npm config set proxy http://mydomain%5Cshane:password123@mycompanyproxy:8080
npm config set https-proxy https-proxy://mydomain%5Cshane:password123@mycompanyproxy:8080
npm config set http-proxy http-proxy://mydomain%5Cshane:password123@mycompanyproxy:8080

Final Thoughts

I hope this solution has resolved your issue. If any other solutions work for you, please post them in the comments below to help others out there.

Shane Bartholomeusz