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

23

55

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

Morlee answered 19/7, 2012 at 3:39 Comment(10)
Which version of NuGet are you using?Sato
Are you behind a proxy ?Stilliform
Its version 2.0.30619.9119. I do not believe I am behind a proxy, I can access nuget.org on my browser no problem.Morlee
The default NuGet.org feed is located at nuget.org/api/v2. Can you verify whether you can access the package source URL in the browser as well and ensure the NuGet settings point to this URL?Loading
I realised I had set the HTTP_PROXY environment variable (so that I could use HTTPie with Fiddler as it happened) - I didn't realise that Nuget made use of this and, since I didn't have Fiddler running at the time, it failed to connectKosak
It might be that there is a package source configured in tools->options-> package manager ->package source that nuget is not able to reach?Claudy
@Mark This helped me too. Why don't you post this as an answer and accept it yourself?Dimmick
2.In the Run text box, copy (CTRL+C) and paste (CTRL+V) or type the following: reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /fGutturalize
Its working for me ....try itGutturalize
For me the fix was to remove an old package source that was disabled in settings. Fiddler showed that Visuals Studio were trying to download packages from it.Lorindalorine
C
48

Clearing HTTP_PROXY worked for me.

Let me fix it myself

Important: This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base: 322756 How to back up and restore the registry in Windows

To reset your Internet Explorer proxy settings yourself, follow these steps:

  1. On Windows XP, click Start, or on Windows Vista or Windows 7, click , and then click Run. On Windows 8 or Windows 8.1, to access the Run command, press the Windows logo key Windows logo key + R. Or, swipe in from the right edge of the screen, and then tap Search (or if you are using a mouse, point to the upper-right corner of the screen, move the mouse pointer down, and then click Search). Type Run in the search box, and then tap or click Run.
  2. In the Run text box, copy (CTRL+C) and paste (CTRL+V) or type the following: reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
  3. Click OK.
  4. On Windows XP, click Start , or on Windows Vista or Windows 7, click , and then click Run. On Windows 8 or Windows 8.1, to access the Run command, press the Windows logo key Windows logo key + R. Or, swipe in from the right edge of the screen, and then tap Search (or if you are using a mouse, point to the upper-right corner of the screen, move the mouse pointer down, and then click Search). Type Run in the search box, and then tap or click Run.
  5. In the Run text box, copy (CTRL+C) and paste (CTRL+V) or type the following: reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /f
  6. Click OK.

From http://support.microsoft.com/kb/2289942 Thanks @Sandy

Cryoscopy answered 23/3, 2013 at 15:45 Comment(6)
Where do you do that?Sesqui
Navigate to support.microsoft.com/kb/2289942 and search for 'Let me fix it myself'. BTW this answer fixed my problem and now I deserve all the 14 upvotes for above comment :-PFile
I dont know how it got set, but there was an "http_proxy" environment variable set. I removed the environment variable, close Visual Studio 2013, cleared the cache using ipconfig /flushdns command and reopened the solution is Visual Studio. Now I was able to download the Nuget packages using the install-package commandDoviedow
For VS2015: I am commenting because none of the solution worked for me. I base my response on the answer about getting rid of the <system.net> section. My sections looks like this: <system.net><settings><ipv6 enabled="true"/></settings></system.net> What I did was to: removed the section and restarted VS 2015. That made it work. But then, I added the section back again with enabled="false" restarted VS2015 and it worked again. So, I set the enabled back to true, tried again and VS2015 worked fine.Stoke
Another possible cause for this error is the proxy for the account that's running the TFS build service. In order to fix that situation, log in as the build service account and set up the proxy there. This was my problem with connecting to NuGet, and it took a while to figure out.Drandell
This resolved my issue after clearing out my proxy settings.Kerbela
C
44

Solved. that's because Visual studio is using fiddler http connection.

all you have to do is to open fiddler=> fiddler option => connection => uncheck "act as system proxy on startup".

thats all!

Capablanca answered 19/1, 2014 at 16:53 Comment(2)
Thanks! I also had to close fiddler before it took effect, or maybe there was a short delay.Moira
I tried this but still get an error for github.com, which seems to be similar to the nuget.org issue.Siphonophore
C
27

This started happening to me quite randomly today on Visual Studio 2012. A bit simplistic but, after checking if the Nuget site itself was up and trying the Package Manager Console, my solution was to:

Close and reopen Visual Studio

Suddenly it could connect to the Nuget server again and download my much needed packages.

Chinese answered 19/3, 2014 at 17:2 Comment(5)
... when in doubt reboot visual studio. Should have known ಠ_ಠCampbellite
The mother of all truths... feeling blessed :)Dibru
this might be related to my issue with github.com as well #39129934Siphonophore
Great! I don't know why but it does work. By the way, I met a lot of such kind of things when I struggle with some configuration or software. So it probably becomes the first option of all the solution for me in the future. ThanksGenital
This worked for me. Not sure why error came for me.Diaspore
A
12

Tools -> Library Package Manager -> Package Manager Settings -> Clear Package Cache

That worked for me

Apiarist answered 13/6, 2013 at 10:4 Comment(0)
S
6

Clearing the Proxy Cache in IE Fixed this for me. Use these two command lines in the command prompt (run as administrator)

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f

then

reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /f

The details can be found at https://support.microsoft.com/en-us/kb/2289942

Sake answered 26/5, 2015 at 11:47 Comment(2)
This worked for me, however the second line returned: "ERROR: The system was unable to find the specified registry key or value."Mulvey
@DamianGreen That is not a problem, it is simply deleting an entry that you don't want IF it is there. If it isn't, you'll see that message and there's no need to be concerned. I'm glad it worked for you!Sake
C
5

I solved it on mine by commenting out the

<system.net></system.net>

section from the devenv.exe.config located at

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe.config
Callaghan answered 12/12, 2014 at 4:2 Comment(2)
This was the solution that finally worked for me. Deleting the .user file would work temporarily but it would always come back. The system.net section has a setting that appears to be trying to use IPv6, so commenting out this section disables that.Rae
for what you thought it involved the devenv.exe BUT in fact you can test the connection to https://api.nuget.org/v3/index.json using a browser so it does not matter how the VS connects to that here. That config file should be unknown to a browser installed on your computer. The problem here is somehow that address is blocked, using a proxy can help connect to that.Biff
A
4

Here's how I fixed this issue after none of the suggestions above worked:

Internet Explorer > Tools > Connections > Lan Settings
Uncheck 'Automatically Detect Settings' box. This solved the Nuget Package Manager issue for me. Additionally it fixed another connectivity problem I was having with a VMWare virtual desktop AND... it greatly increased speed in Internet Explorer when trying to connect to secure sites.

Alliteration answered 7/11, 2015 at 22:29 Comment(0)
D
1

I had this issue with VS 2010 package restore even after updating the Nuget Package Manager to the latest and also unselecting all package sources I could. I was getting an error while enabling the Nuget Package Restore option on the solution.

I resolved this by using a different box that didn't have restricted https access to the nuget server. When I used VS 2012 from a different box to enable package restore, it worked fine. I believe it needs to be able to connect to the nuget online server to download the latest nuget.exe used during restore operations. So one option you can use is to perform the Enable Package Restore process from a server that has all the internet access necessary, and then check-in the changes. Once these changes are checked-in, you can then load the solution again from VS 2010 or VS 2012 and use the nuget restore capabilities.

Hope that helps!

Duplet answered 4/3, 2014 at 23:42 Comment(0)
I
1

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.

Inextricable answered 11/3, 2019 at 14:9 Comment(0)
O
0

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.

Oculus answered 14/11, 2013 at 21:18 Comment(0)
A
0

Had the same issue, it was solution specific, and none of the above worked. I deleted the visual studio solution user options file (.suo) and restarted VS 2013 and now I can update and install packages again.

Ardussi answered 1/10, 2014 at 20:26 Comment(0)
C
0

Finally resolved. I disabled an extension in Chrome. I had installed it to hide my real location.

Callant answered 4/12, 2014 at 5:36 Comment(0)
G
0

To reset your Internet Explorer proxy settings yourself, follow these steps:1.On Windows XP, click Start, or on Windows Vista or Windows 7, click

2459687, and then click Run. On Windows 8 or Windows 8.1, to access the Run command, press the Windows logo key

Windows logo key+ R. Or, swipe in from the right edge of the screen, and then tap Search (or if you are using a mouse, point to the upper-right corner of the screen, move the mouse pointer down, and then click Search). Type Run in the search box, and then tap or click Run. 2.In the Run text box, copy (CTRL+C) and paste (CTRL+V) or type the following:

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f

3.Click OK. 4.On Windows XP, click Start , or on Windows Vista or Windows 7, click

2459687, and then click Run. On Windows 8 or Windows 8.1, to access the Run command, press the Windows logo key

Windows logo key + R. Or, swipe in from the right edge of the screen, and then tap Search (or if you are using a mouse, point to the upper-right corner of the screen, move the mouse pointer down, and then click Search). Type Run in the search box, and then tap or click Run. 5.In the Run text box, copy (CTRL+C) and paste (CTRL+V) or type the following: reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /f

6.Click OK.

Gutturalize answered 19/12, 2014 at 19:0 Comment(0)
P
0

i could not install globalize in V.S. 2015 and after trying all the answers i tried this. I opened my project in V.S. 2013 and it worked 1st time. hope this helps somebody else

Priebe answered 3/11, 2015 at 18:51 Comment(0)
L
0

Modem re-start fixed my problem.!

Lananna answered 4/11, 2015 at 11:29 Comment(0)
D
0

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

Deraign answered 8/5, 2018 at 12:17 Comment(0)
C
0

I fixed it by uninstall the system proxifier : WideCap

Chaisson answered 11/8, 2018 at 1:54 Comment(0)
S
0

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)

Scales answered 16/9, 2018 at 13:1 Comment(0)
T
0

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.

Tameika answered 17/9, 2018 at 18:39 Comment(1)
I absolutely hate when my company does things like this.Amparoampelopsis
C
0

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.

Crisp answered 22/10, 2018 at 19:11 Comment(0)
E
0

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.

Eupatorium answered 15/6, 2022 at 14:18 Comment(0)
Z
-1

Internet Properties -> LAN Settings -> uncheck "Automatically detect settings"

Zounds answered 21/4, 2013 at 17:8 Comment(1)
It would be helpful for you to include why this is supposed to work as well as where this menu lives.Chilson
A
-2

Steps:

  1. Close Fiddler.
  2. Restart Visual Studio.
Azaleeazan answered 3/6, 2015 at 6:32 Comment(1)
It would be better if explain the symptom that you have been faced before, like this answer by @wags1999 #31571724Stenophagous

© 2022 - 2024 — McMap. All rights reserved.