Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget: The remote server returned an error: (504) Gateway Timeout

I'm using Visual Studio 2015 preview CTP 5 and I'm having problems installing some packages.

If I use the NPM UI I get

The remote server returned an error: (504) Gateway Timeout.

If I use the PM Console with Install-Package Ninject.MVC5 I get :

The source at nuget.org [https://www.nuget.org/api/v2/] is unreachable. Falling back to NuGet Local Cache at {userfolder}\AppData\Local\NuGet\Cache
Install-Package : Unable to find package 'Ninject.MVC5'.

If I type: Install-Package Ninject.MVC5 -source nuget.org i get the same UI error :

Install-Package : The remote server returned an error: (504) Gateway Timeout.

I tryied this from other sources that points to solution but none worked. I see a similar problem on nuget but a code 'fix' was release according to the github repo on January, 15.

I'm not sure if this is on my end or a nuget server problem, tryied to reach them at twitter with no response still, don't know what else to try.

like image 793
Bart Calixto Avatar asked Feb 02 '15 22:02

Bart Calixto


People also ask

What causes a 504 Gateway Timeout?

A 504 Gateway Timeout error indicates that the web server is waiting too long to respond from another server and “timing out.” There can be many reasons for this timeout: the other server is not functioning properly, overloaded, or down. The other server need not always be external (e.g. CDN, API gateway).

How do I fix Nginx 504 Gateway Timeout error?

A 504 error means nginx has waited too long for a response and has timed out. There might be multiple reasons for the problem. Possible fixes include: Increasing the nginx proxy_read_timeout default of five minutes to be longer, for example, to 10 minutes.


3 Answers

I have found a workaround. Change the NuGet package source to use HTTP instead of HTTPS.

In Visual Studio (2015):
Tools / NuGet Package Manager / Package Manager Settings
Change the Source value of nuget.org from
https://www.nuget.org/api/v2/
to
http://www.nuget.org/api/v2/

If you're using the CLI, you can do the same by using the nuget sources command.

(This workaround obviously removes the encryption on your requests, so anyone sniffing will be able to see what packages you are downloading. Use at your own risk.)

like image 154
MEMark Avatar answered Oct 17 '22 21:10

MEMark


I had the same issue, and after struggling for a couple of hours I finally got it.

There seems to be an issue with the later version of nuget source at url https://www.nuget.org/api/v2/

To fix the issue...go to Tools -> NuGet Package Manager -> Package Manager Settings, under Package Sources create a new package source
Name: NugetSource
Source: http://packages.nuget.org/v1/FeedService.svc/

Move the newly created source to the top of the list under Available package sources. Click OK and restart Visual Studio.

like image 7
Maxwell Maake Avatar answered Oct 17 '22 21:10

Maxwell Maake


Another workaround is to use an HTTP proxy when installing NuGets.

Use for example ProxyDNS (http://proxydns.co/) by setting these in Windows Network and Sharing Center => [select your network connection] => Properties => Internet Protocol Version 4 (TCP/IPv4) => Properties => Use the following DNS server addresses:

Preferred DNS server: 74.207.242.213

Alternate DNS server: 50.116.28.138

proxy settings

The reason this works (perhaps, I'm not a network expert) is that the problem seems so be some sort of name resolution (DNS) problem related to the content delivery network (CDN) that NuGet is using for hosting the packages.

For example, today I couldn't get xunit 2.0 installed and the reason is that https://az320820.vo.msecnd.net/packages/xunit.assert.2.0.0-rc1-build2826.nupkg returned with (504) Gateway Timeout. If I use HTTP instead of HTTPS http://az320820.vo.msecnd.net/packages/xunit.assert.2.0.0-rc1-build2826.nupkg the package downloads OK.

I have used ProxyDNS to get around the problem and this has worked every time so far.

like image 1
jussi.mattila Avatar answered Oct 17 '22 23:10

jussi.mattila