Visual Studio – NuGet – No connection could be made because the target machine actively refused it 127.0.0.1:8888


Have you ever had the problem after installing / updating Visual Studio Enterprise / Pro / Community and when trying to use NuGet, you get the following error message?

“[nuget.org] Unable to load the service index for source https://api.nuget.org/v3/index.json.

An error occurred while sending the request.

Unable to connect to the remote server

No connection could be made because the target machine actively refused it 127.0.0.1:8888″

I’ve had this message a little while back and fixed the problem. Then yesterday I updated Visual Studio and the problem come back. It took me a little while to find how to fix the problem, so I decided to blog about it in case it happens again.

Now, I’m not 100% sure what caused it, but it is proxy related problem. I do have Zscaler on my machine (which I have no control over), I also have fiddler. Maybe one of them is causing the problem. Whatever causing the problem, it’s a very simple fix.

Open the file devenv.exe.config in a text editor. This can be found at the following location:

C:\Program Files (x86)\Microsoft Visual Studio\<Year>\<Version>\Common7\IDE

e.g.,

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE

Find (mine was near the bottom of the file) and add the following:

  <defaultProxy enabled="true" useDefaultCredentials="true">
      <proxy usesystemdefault="true" bypassonlocal="true" />
   </defaultProxy>
 

So, it looks like:

<system.net>
    <defaultProxy enabled="true" useDefaultCredentials="true">
      <proxy usesystemdefault="true" bypassonlocal="true" />
    </defaultProxy>
    <settings>
      <ipv6 enabled="true"/>
    </settings>
  </system.net>

Restart your Visual Studio and then navigate to add Nuget packages.

Advertisements