10

I am using VS 2010 (Package Manager Console) to download NuGet (2.5.40416.9020/Latest) packages. It uses URL https://nuget.org/api/v2/. It gives me error as below.

Install-Package : An error occurred while loading packages from'https://nuget.org/api/v2/': The remote name could not be resolved: 'nuget.org'
At line:1 char:16
+ Install-Package <<<<  Rx-Main
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

But when i access the same URL via browser then i am able to browse the site. I am on corporate network so firewall might block the port (Other than 80 and 443).

So which port is used by NuGet while downloading packages via Package Manager Console (VS 2010)?

vijay
  • 1,323
  • 1
  • 11
  • 15

4 Answers4

7

https://nuget.org/api/v2/ means port 443 (the standard port for HTTPS)

If you're on a corporate network, port 80 and 443 are usually bounced through a proxy server.

Most likely, NuGet is not using your proxy settings for some reason, so it cannot find the proxy server and are stopped by the corporate firewall.

Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294
  • But 443 is not blocked on firewall and i am able to browse the https://nuget.org/ site, but it gives me error when i run command through Package Manager Console. – vijay Jun 06 '13 at 08:12
  • @vijay I'm fairly sure the browser you're using has a proxy set, and NuGet has not picked those settings up automatically. There's an example [here](http://stackoverflow.com/questions/9232160/nuget-behind-proxy) on how to set proxy settings up for NuGet 1.4 or later. – Joachim Isaksson Jun 06 '13 at 08:15
  • Thanks @Joachim for you reply. I have set the proxy address. But now i am getting new error. `The remote server returned an error: (502) Bad Gateway`. – vijay Jun 06 '13 at 08:26
  • @vijay Sounds like there's still [something wrong with the proxy](http://www.checkupdown.com/status/E502.html) then. Possibly, you've configured the HTTP proxy for HTTPS or the reverse, or the proxy does not support all proxy commands required for NuGet. – Joachim Isaksson Jun 06 '13 at 09:02
  • Thanks @Joachim its resolved now. I have updated proxy settings for visual studio config as well and its started working. :) Thanks once again. – vijay Jun 06 '13 at 09:32
  • sometimes its a TLS version mismatch. in powershell: `[System.Net.ServicePointManager]::SecurityProtocol`... if outputs 'ssl3, tls' you might be using an outdated tls version not supported by your nuget.org: source: https://devblogs.microsoft.com/nuget/deprecating-tls-1-0-and-1-1-on-nuget-org/ – rjminchuk Jan 07 '21 at 22:38
3

Go to file Program Files\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe.config

Set ipv6 enabled from true to false

        <system.net>
            <settings>
                <ipv6 enabled="false"/>
            </settings>
        </system.net>
satish suthar
  • 369
  • 3
  • 7
2

In my case, adding the package source references (URLs that you are using to get the packages) manually in the Nuget.Config file (\users*\appdata\Roaming\Nuget\Nuget.Config) resolved the issue.

Make sure that all the nuget packages that you are referring in the solution were added to the above Nuget.Config file.

For some reason, the references got removed from my config file and i started getting this exception. Adding them manually to the config file resolved the issue in my case.

Murali .K
  • 21
  • 2
  • 4 hours later. Thanks for posting! – Nimblejoe Nov 10 '18 at 01:12
  • My problem was that the company proxy settings were added to this file I believe via a NuGet.config file that I was working with in a solution. I'm guessing that it took those proxy settings and updated the one under my profile. It appears that the only way to back it out is to manually edit this file. This setting was blocking me from getting packages from our internal company feed. – Nimblejoe Nov 10 '18 at 01:19
1

I was unable to download the nugget package through the console, it was giving error like:

"Unable to connect remote server"

I followed the above steps and Set ipv6 enabled from true to false. It resolved my problem.

C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe.config

<system.net>
     <settings>
         <ipv6 enabled="false"/>
     </settings>
</system.net>
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129