27

I am getting this error:

[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 A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 185.82.212.95:8080

John Smith
  • 7,243
  • 6
  • 49
  • 61
Ajit Pawar
  • 271
  • 1
  • 3
  • 7

8 Answers8

27

I was having same issue in VS 2017. You would need to enable proxy settings for VS, so that it can use existing IE proxy to reach out internet. This is especially useful, for those users, who uses office laptops and proxy settings are managed by group policies and IE settings get updated automatically. It would have been great if there was an option within VS IDE itself to add proxy just like Eclipse IDE has.

Solution

  1. Go to your Visual Studio install location as below -

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

  1. Open devenv.exe.config file as an Administrator.

Add defaultProxy tags as below, within the existing system.net tag -

<system.net>
    <defaultProxy enabled="true" useDefaultCredentials="true">
        <proxy usesystemdefault="true" bypassonlocal="true" />
    </defaultProxy>
  <settings>
    <ipv6 enabled="true"/>
  </settings>
</system.net>
  1. Restart VS.
Frederik Struck-Schøning
  • 12,981
  • 8
  • 59
  • 68
Indranil
  • 1,776
  • 1
  • 17
  • 22
19

TLDR ;)

Ok, let's get started to fix this issue :)

First, you need to navigate the Visual Studio instance and for that do the following:

  1. Open Properties on VS shortcut and then click on "Open File Location"

    enter image description here

  2. Edit as administrator the devenv.exe.config with Notepad++ or other editors you prefer:

    enter image description here

  3. Navigate to the end of a file and check if you don't have <defaultProxy>... section:

    enter image description here

  4. Make sure to add following inside <system.net>:

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

The final result should be like this:

enter image description here

A few notes:

  1. If you have several Visual Studio instances then make sure you edited devenv.exe.config for each one.
  2. Sometimes after VS updates, these files content can reset. So a good hint here is that once you Update Visual Studio instance, then go and check the .exe.config file.

Update: Btw, the same kind of approach work for many other applications, for example, check this post.

Arsen Khachaturyan
  • 7,904
  • 4
  • 42
  • 42
0

I have faced the same problem with VS 2015 Go to the following folder

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

and add In my case is already present added the highlighted text

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

Solved my issue

Frederik Struck-Schøning
  • 12,981
  • 8
  • 59
  • 68
Vamsi J
  • 601
  • 6
  • 8
0

I got this error using VSTS as source provider (git). Was logged in to a MSDN account in VS2017 based on the correct email address, i.e. same as the one used for my VSTS login. Upon restoring packages from the VSTS nuget-feed, I would repeatedly be prompted to log in to my MSDN-account, but still get 401 from the source/feed.

Turned out, I apparently had 2 different MSDN-accounts on the same email address - 1 "Personal" account and 1 "Work or school" account.

Solution: simply log in with the correct one (which here turned out to be the Work one)

Frederik Struck-Schøning
  • 12,981
  • 8
  • 59
  • 68
0

The same error is showing for VS2019. For my case Restart the Visual Studio and it's working fine. In my case, it's the network-related issue, you have a proper Internet connection.

Abhishek Kanrar
  • 418
  • 4
  • 6
0

Another method - a workaround - Just do it manually!

I gave up all solutions provided in Github an SO.
Checking the Manage .NET project and item templates docs I just found out that I can install a package locally.

So if anyone is struggling with this, just download .nupkg the package from the source and use the following command

dotnet new -i c:\some-folder\some-package.nupkg

How to download a package manually

  1. Go to Nuget.org
  2. Search for your package and click to see the details
  3. Locate the Download package link, located at the Info section.
  4. Use the command shown above. Cheers! Package installed!
richardsonwtr
  • 153
  • 5
  • 16
0

I get this error intermittently and the devenv.exe.config fix suggested above did not fix it for me. I tried the terminal command below which ran successfully:

dotnet publish -p:PublishProfile=FolderProfile

Subsequent publishes through the IDE were successful. So for me this error seems to be the result of something being cached. I am not sure what starts it.

Ignore
  • 41
  • 5
-2

Please go to Nuget.org and check if the Nuget is up.

enter image description here

Sibeesh Venu
  • 18,755
  • 12
  • 103
  • 140