Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet is returning 503 Server Unavailable

Is there a way to load a package from an alternative server when Visual Studio Package Manager (NuGet) is responding with a "The remote server returned an error: (503) Server Unavailable" message?

like image 511
Talbott Crowell Avatar asked Aug 20 '12 03:08

Talbott Crowell


2 Answers

This is an obscure condition that will likely only occur on an "enterprisy" network environment. If these conditions apply you:

  • you are required to access the Internet via an HTTP proxy server

  • the HTTP proxy server requires a valid user ID & password (or AD authentication) to allow requests to proceed

  • you've been messing with cool developer tools that were ported to Windows from a Linux/Unix environment

  • the new cool tool(s) work after adding the HTTP_PROXY (or possibly HTTPS_PROXY or both) environment variable(s)

  • you can access the NuGet servers from a browser without getting a 503 error

Then it's likely you broke NuGet by inadvertently invoking this configuration feature. I'm not sure exactly how the environment variable breaks NuGet but I suspect NuGet is detecting & using the http_proxy URL but sending an empty user ID & password which causes the HTTP proxy to reject the request.

Fix: remove the environment variable(s) you added and see if the cool tool can be configured to use an HTTP proxy without them.

Update: Ran into a version of this issue with the NuGet config file referenced in the "this configuration feature" link above. Open this file:

%appdata%\nuget\nuget.config

in your favorite editor. If it contains elements with http_proxy or https_proxy then removing these elements may fix the issue too.

PS: Hopefully I'll get an up vote from Colonel Panic :-)

like image 132
Sixto Saez Avatar answered Oct 01 '22 01:10

Sixto Saez


If you have used the package in the past it is probably in your cache. You can add the local cache as an available package source by going into the Library Package Manager Settings under the Tools menu in Visual Studio. For Visual Studio 2012, choose Tools, Library Package Manager, Package Manager Settings, and then click on Package Sources.

In the Available package sources section, type a name like "Cache" and then in for the source, browse to %LocalAppData%\NuGet\Cache. You may need to use Windows Explorer to translate %LocalAppData%\NuGet\Cache into the full path (usually C:\Users\YourAccountName\AppData\Local\NuGet\Cache).

Once you have the Cache as an available source, you can now use the Package Manager Console (found under the View menu under Other Windows or also under the Tools menu under Library Package Manager).

From the Console (which is a PowerShell window with commandlets for NuGet) you can type "get-help NuGet" to see available commands.

Then using Get-Package, you can get a list of Package ID's. Make sure the "Package source" is set to "Cache" (or whatever you called it) and the Default project is set to the project you need manipulate, both of these are dropdowns located at the top of the Page Manager Console. You can also use the Get-Project to verify you are working against the correct project in your solution.

Finally, you can type Install-Package and when prompted enter the Package ID from the output of the Get-Package commandlet.

like image 43
Talbott Crowell Avatar answered Oct 01 '22 02:10

Talbott Crowell