nugetdotnet-restore

Dotnet restore fails due to api.nuget.org/v3/index.json


I am having a .NET Core 2.1 application and can not run dotnet restore anymore.
I am getting this error :

Restoring packages for D:\Work-2\Anubis\Core\AnubisServer.Server\AnubisServer.
Server.csproj... Restore completed in 22.22 ms for D:\Work-2\Anubis\Core\COM\SharedCOM\SharedCO
M.csproj. Restore completed in 26.09 ms for D:\Work-2\Anubis\Core\AnubisServer.Shared\An
ubisServer.Shared.csproj. Restore completed in 26.07 ms for D:\Work-2\Anubis\Core\Server\Extensions\Exte
nsions.csproj. Restore completed in 26.12 ms for D:\Work-2\Anubis\Core\AnubisServer.Client\An
ubisServer.Client.csproj. C:\Program Files\dotnet\sdk\3.0.100-preview-009812\NuGet.targets(114,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json
. [D:\Work-2\Anubis\Core\AnubisServer.Server\AnubisServer.Server.csproj] C:\Program Files\dotnet\sdk\3.0.100-preview-009812\NuGet.targets(114,5): error : The SSL connection could not be established, see inner exception. [D:\Work-2\
Anubis\Core\AnubisServer.Server\AnubisServer.Server.csproj] C:\Program Files\dotnet\sdk\3.0.100-preview-009812\NuGet.targets(114,5): error : Unable to read data from the transport connection: A connection attempt faile
d because the connected party did not properly respond after a period of time, o
r established connection failed because connected host has failed to respond.. [
D:\Work-2\Anubis\Core\AnubisServer.Server\AnubisServer.Server.csproj] C:\Program Files\dotnet\sdk\3.0.100-preview-009812\NuGet.targets(114,5): error : A connection attempt failed because the connected party did not properly resp
ond after a period of time, or established connection failed because connected h
ost has failed to respond. [D:\Work-2\Anubis\Core\AnubisServer.Server\AnubisServ
er.Server.csproj]

As you can see it all resolves around api.nuget.org/v3/index.json but i do not know what is wrong.

I have looked upon previous answers and i tried:

-deleting the Nuget folder from C:/Users:/[username]/Nuget
-looking into C:\Users\[user]\AppData\Roaming\NuGet.config file and see if all urls are ok

Nuget.config

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

What is curious for me is that it worked perfectly until today.I have not made any system changes.


Solution

  • If you look at the error message you'll see:

    error : Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

    so, as you can see, NuGet is having network problems trying to talk to nuget.org. You could try opening your web browser and see if you're able to open https://api.nuget.org/v3/index.json there. But just because it works in your browser doesn't mean it's going to automatically work from nuget.exe, devenv.exe (visual studio), dotnet.exe and so on.

    There are many reasons why this might happen, and I can't possibly list every single one, but if you're using a work computer, perhaps your IT department have blocked outgoing web access and used Group Policies to force your web browser to use a proxy. Maybe they configured your computer's firewall to forbid all programs from using the network, except those on a whitelist (web browser, mail client, corporate apps).

    Or maybe there was just a temporary or localised network issue. nuget.org is behind a CDN and if the CDN node closest to you was having problems.

    For people who want to contact NuGet.org about the site being down, their FAQ asks you to use MTR to get network information that is needed by the CDN provider to diagnose these issues. The thing I'm trying to point out is that MTR is a useful tool in diagnosing network issues on your side that website maintainers aren't able to monitor themselves.