Visual Studio/C#: Nuget Unable to connect to remote server

Viewed 81793

In MS Visual studio, I'm trying to install Nuget packages into my solution.

When I choose the option "Manage Nuget Packages for Solution" and attempt to install a package, I get the message "Unable to connect to the remote server".

I do have Internet connection so do not understand why I always get this message.

Is anyone aware of some steps that can be taken to rectify this issue?

Thanks

23 Answers

Restarted Visual Studio twice solved my problem.

First, I restarted but it did not work. Then, I did almost everything but still didn't work.

Then, restarted again solved my problem.

I had the same symptoms, and apparently visual studio was using some proxy setting set up in IE. It turned out that my problem was one of the following:

  • My IE had been updated to IE 9, but the update wasn't completed because I hadn't completed the 'update wizard'
  • Some obscure proxy setting was set up in IE (a remnant of a selenium RC test run)

After completing the update wizard, and clearing all proxy settings, my NuGet package manager was working again.

In my case(visual studio 2012-windows10 OS) the problem was with security protocols. Only TLS 1.2 was the enabled protocol and TLS1.1 and TLS1.0 was disabled for some reason. So going into registry and making changes to enable TLS1.0 and TLS1.1 solved the problem.

To enable these protocols you can follow directions on here

I fixed it by uninstall the system proxifier : WideCap

That happened to me when I tried to use Visual Studio from home being connected via public WiFi and my work station was configured to block connections in/out from Internet to VS2017. Check you local firewall setting and ensure that you have Allow for VS2017 when on Public network. (in Windows Defender Firewall & Advanced Security)

nugget.org was blocked in my network for security reason so all the nugget packages are installed from Artifactory via JFrog. After configuring my nugget package manager setting to the link provided by my employer the problem is resolved.

One route that I haven't seen people mentioning is setting the proxy for Nuget in your user folder.

Browse to C:\Users[yourProfile]\AppData\Roaming\Nuget and change your Nuget.config file to the following:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
   <add key="http proxy" value="http://yourProxy.yourCompany.org"/>
  </config>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

We set this setting and then Nuget immediately worked.

Ok, but now I get a credentials prompt!

If you also end up getting a credentials prompt when trying to load packages from Nuget in Visual Studio, you should try to manually browse to http://www.nuget.org/downloads. I've seen proxies like BlueCoat display a Content Filter Warning the first time someone visits a site, and since you can download content from Nuget, it get's flagged.

So you may need to browse there one time to click 'Accept Terms', and then you'll be able to access it.

If you are using a developer server, sometimes the TLS is not active. Reach with regedit.exe the following path of register, and if not present, add the following keys. Reboot and try again nuget online from visual studio.

To enable TLS 1.2 support in Windows Schannel From Notepad.exe, create a text file named tls12-enable.reg.

Copy, and then paste the following text. Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2]
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"DisabledByDefault"=dword:00000000
"Enabled"=dword:00000001
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"DisabledByDefault"=dword:00000000
"Enabled"=dword:00000001

Save the tls12-enable.reg file. Double-click the tls12-enable.reg file. Click Yes to update your Windows Registry with these changes. Restart your computer for the change to take effect.

Related