245

While trying to connect to Nuget, I'm getting the error below, and then I am unable to connect:

[nuget.org] Unable to load the service index for source https://api.nuget.org/v3/index.json. An error occurred while sending the request. Unable to connect to the remote server 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 68.232.34.200:443

I am able to access https://api.nuget.org/v3/index.json on my browser.

bmike
  • 917
  • 2
  • 22
  • 41
DarthVader
  • 52,984
  • 76
  • 209
  • 300
  • Possible duplicate of [VS2015 nuget package manager not finding packages](http://stackoverflow.com/questions/36386895/vs2015-nuget-package-manager-not-finding-packages) – Linda Lawton - DaImTo Dec 16 '16 at 13:29
  • Since you have post the same issue on another thread (http://stackoverflow.com/questions/41157069/nuget-not-connecting), please continue this issue on your previous thread. And I also will follow this issue on your previous thread. – Weiwei Dec 19 '16 at 01:42
  • Do you have proxy configured on your machine? Or "http_proxy" variable configured in environment variable? – Eddie Chen - MSFT Dec 20 '16 at 02:54
  • Yes I have multiple proxies running on my machine. When I installed fiddler. I was able to access to nuget. I have corp proxy. – DarthVader Dec 20 '16 at 10:30
  • @DarthVader, if Eddie's reply help you resolve this issue, would you please mark it as the answer? Have a nice day:) – Jack Zhai Dec 30 '16 at 03:49
  • 7
    I just restarted my Visual studio and it worked! – Shridhar R Kulkarni May 13 '20 at 04:41
  • Restarting VSCode + Pulling Updates seemed to resolve it for me as well. I think there might have been dependancies that VSCode didn't prompt me for upon initial `build` command but when I restarted, it asked me to confirm downloading/install dependancies. – FreeSoftwareServers Nov 27 '20 at 20:37
  • I downgraded from VS 2019 to VS 2017 and it worked for me. The project solution was meant to be opened in VS 2017 but I had installed VS 2019 on my machine in error. – RBT Aug 03 '21 at 09:26
  • For me, the exact same nuget API URL works within Visual Studio but not on the command line (ie for .NET 5) – PandaWood Aug 04 '21 at 03:44
  • I was also facing the same problem when run docker file in VS code, after spending 4 hours come to know that need to add these two lines in docker files and all well ARG HTTP_PROXY=http://your_proxy:port/ ARG HTTPS_PROXY=http://your_proxy:port/ – Saad Awan Feb 20 '22 at 06:58

55 Answers55

158

Deleting %AppData%\Roaming\NuGet\NuGet.Config and restarting VS2019 worked for me.

Similar to https://github.com/NuGet/Home/issues/3281

isherwood
  • 58,414
  • 16
  • 114
  • 157
janonimus
  • 1,911
  • 2
  • 11
  • 11
  • I am using VS 2017, works for me too. – Akhil Shukla Jun 08 '22 at 14:00
  • 8
    I am using VS 2022 and this worked for me, just deleted the file, restarted VS and after that I executed dotnet restore from the nuget package manager console. – Dayán Ruiz Jul 12 '22 at 09:33
  • Since this question is used for discussing *all* errors with "Unable to load service index", here's a hint which MAY work for you: instead of deleting the whole NuGet.Config, CONSIDER removing **unrelated** sources which **no longer work**. Sometimes NuGet fails to install a package if a **completely unrelated source doesn't work** (in my case, it was obsolete MyGet source which stopped another MuGet source from working). – Athari Aug 18 '22 at 16:03
  • 13
    if this doesn't work for you, just make sure `\Roaming` isn't already part of the `%APPDATA%` path. – kayleeFrye_onDeck Sep 01 '22 at 01:41
  • 3
    open the file %AppData%\Roaming\NuGet\NuGet.Config and see if you have some nuget sources pointing to 3rd party components like Telerik, dev express , etc , that you no longer have on your system – Oscar Agreda Oct 07 '22 at 23:45
  • For other people struggling, this also does the trick if you're having issues with a private source (in my case, a GitHub Repo Source), verified that your PAT/account data is valid and still getting these errors. Simply delete the nuget.config and restart your IDE / run dotnet build/restore, it will somehow restore some corrupted indexes somewhere. Then add your private source back in and voilá. – Till Riemer Nov 10 '22 at 12:32
  • I have no idea why I have a source "https://packagesource" and who puts it there, but your answer solved the issue for me! – Rickless Nov 12 '22 at 09:44
  • I assume this advice would only recreate the nuget.org package store. If you have any private package stores you would have to add them in again manually. For me, I didn't need to delete the whole NuGet.config file. Instead I just needed to remove the private package store previously added for a customer project, which I now no longer had access to. My other private package stores remained in the list. – Simon Elms Nov 29 '22 at 20:24
  • 2
    What should be done by MacOS users in this case? – Rafael Dec 18 '22 at 19:53
  • If you have any custom feeds, **this will delete them, and they're not in source control**. Try less destructive options first, and if you try this, hide the file rather than deleteing it. – bbsimonbb Feb 28 '23 at 10:34
51

You need to add proxy settings into Nuget.Config file. Refer to this link for details: Nuget Config Section & Nuget Proxy Settings.

Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60
  • For me it was that I had a http_proxy environment variable set up that was wrong. – Martin Brown Mar 13 '17 at 13:34
  • 4
    I had that problem too, and removed it in the command line, but now the problem is back but I have no proxy set currently. Any idea what could still be going wrong? – Dan Csharpster Aug 08 '17 at 14:28
  • 8
    The config file should be present at %AppData%\NuGet\ or C:\Users\WindowsLoginName\AppData\Roaming\NuGet – VivekDev Jan 25 '20 at 07:44
  • For me I encountered the issue when I try to run dotnet command build in my linux machine, how to set the proxy for nuget on linux? – Derrick.X Mar 24 '21 at 06:27
  • 2
    For me, I was restoring a nuget package during a docker build. To do that the NuGet.config has to be copied into /root/.nuget/NuGet/NuGet.Config. This was a private feed and the PAT in the NuGet.Config had expired. Refreshing the PAT fixed the issue. – DrBB May 19 '22 at 18:16
  • In my case nuget fails with this error only using dotnet cli v6, using VS2019/Net Framework, nuget restores and works fine - on the same machine - which rules out any of the answers here as far as I can tell – PandaWood Sep 22 '22 at 23:07
42

I was getting the same error while trying to browse the NuGet Package, to resolve the same followed below step:

1- go to %appdata%\NuGet\NuGet.config

2- Verify the urls mentioned in that config

3- Remove the url which is not required

4- Restart visual studio and check

John Smith
  • 7,243
  • 6
  • 49
  • 61
  • 3
    Very helpful, to get to this nuget setting / config location: %appdata%\NuGet\NuGet.config. In my case, I was trying to install a dotnet global tool, and for some *frustrating* reason it kept trying to use a myget nuget source, even though there was no reason for that. I do have a myget source listed (by necessity as it's used in one proj), but the main nuget.org source / url still was listed first, and this install wasn't actually uploading to either package registry anyways, just on local machine. Anyway by temporarily removing the myget source in this file it suddenly worked. – Nicholas Petersen Mar 04 '21 at 21:06
  • 1
    you dont need to remove it you can disable it – Emil Apr 05 '21 at 01:11
36

A developer of the nuget-package manager suggested in 2019 to disable tls 1.3 as a workaround (see issue 7705).

Open Registry Editor by pressing Win + R and type regedit Enter

Navigate to:

\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client

Change the value of DisabledByDefault key 0 to 1

Then restart the Visual Studio.

Read more about TLS on wikipedia
Read more about issue 7705 w.r.t. NuGet at github

3rd party edit

Be aware that this disables tls 1.3 for the os not just for nuget or dotnet.
Windows 10 version 1909 did contain an experimental implementation of TLS 1.3 but later versions should be fine. Based on one answer from Unable to browse nuget packages you can test if tls is the problem via a console programm

static async Task Main(string[] args)
{
    var client = new HttpClient();
    string uri = "https://apiint.nugettest.org/v3-index/index.json";
    var response = await client.GetAsync(uri);
    string msg = "If you see this, your machine has no TLS/SSL issues with nuget.org";
    Console.WriteLine(msg);

}
surfmuggle
  • 5,527
  • 7
  • 48
  • 77
Harsha
  • 549
  • 4
  • 10
  • Thanks. This did the trick for me. I was getting below error "Error occurred while restoring NuGet packages: Unable to load the service index for source https://api.nuget.org/v3/index.json. [nuget.org] Unable to load the service index for source https://api.nuget.org/v3/index.json. An error occurred while sending the request. The request was aborted: Could not create SSL/TLS secure channel". – chanakya sankritayana Nov 15 '19 at 07:38
  • It worked. But why? What could cause this problem? How did something dare to change the registry like that? And for what? – peanut Nov 15 '19 at 10:49
  • 3
    **As per my knowledge**, this registry key `DisabledByDefault` value is 1 on windows 10 default settings. however, windows updater or visual studio updater may change it to 0. that's why visual studio failed to connect `https` secure site. – Harsha Nov 15 '19 at 11:29
  • 1
    This trick actually solved the problem and my other .NET apps as well! –  Nov 24 '19 at 17:27
  • 13
    I have same problem as OP. In my Windows 10 box registry, Protocols folder is empty (no TLS 1.3 option nor anything inside). – Eduardo Álvarez Jul 16 '20 at 17:56
  • 11
    Exactly I don't see any folders under Protocols folder. Also, I checked Internet Options from the Internet Explorer, TLS 1.1 and TLS 1.2 are checked. Not sure why there are no folders under Protocols in the Registry Editor. Can someone tell me what am I missing here? @EduardoÁlvarez – Swap Aug 20 '20 at 02:18
  • 6
    For those that say the TLS 1.3 keys dont exist. Just create them. It will work after this – glenho123 Jan 16 '21 at 21:07
  • 1
    Thanks for the good diagnostic. But this and other registry edits and numerous restarts still have not helped solve the problem. Happens inVS2022 and LinqPad7 and 5. – Daniel Williams Aug 13 '22 at 20:01
  • Did you mean `DisabledByDefault` **property** (instead of **key**)? – Martin Schneider Oct 28 '22 at 12:19
14

Go to

Settings ( Global Settings of your PC ) > Network and Internet > Proxy > Automatic Proxy Setup > and set Automatically detect settings to off.

VISHAL TANK
  • 215
  • 4
  • 9
14

This can also happen due to authentication issues, so you may need to re-authenticate to Visual Studio.

In that case, you can simply run the following command from the folder where your package.config file is located (usually you project's root):

dotnet restore --interactive

You will be prompted to visit a pairing URL from your browser and enter a pairing code, for instance:

To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code C2DEJ87H to
authenticate.

This requires the .NET CLI, which is included in the .NET Core SDK that can be installed from https://learn.microsoft.com/en-us/dotnet/core/install/windows

Furthermore, if no sign-in prompt appears upon running the nuget restore command, your installation may be missing the artifacts-credprovider nuget plugin, which you can install with:

iex "& { $(irm https://aka.ms/install-artifacts-credprovider.ps1) }"
Pierre Thalamy
  • 311
  • 1
  • 3
  • 14
  • That was actually my case. I had to login into visual studio – anhoppe Oct 28 '22 at 14:34
  • This is the only answer that worked for me. Embarassingly, I'd tried out all of the answers on page 1, went away and discovered this solution independently, came back to add it as an answer, but found it was already here on pg 2! – shapeshifter42 Nov 01 '22 at 12:16
13

If you see error as follow, you may need to set up your Azure Artifacts Credential, see this Github link, you could either install the credential provider by running a powershell script or manually.

error :   Response status code does not indicate success: 401 (Unauthorized).
Jonathan Chow
  • 1,207
  • 1
  • 9
  • 11
11

I have stumbled across this issue when trying to run nuget.exe via Jenkins (configured as a service, by default using Local System account). I have edited C:\Windows\System32\config\systemprofile\AppData\Roaming\NuGet\NuGet.Config file which looks like the following:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <config>
        <add key="http_proxy" value="http://proxy_hostname_or_ip:3128" />
        <add key="https_proxy" value="http://proxy_hostname_or_ip:3128" />
    </config>

  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>

</configuration> 

In order to test command prompt can be started via PSTools:

psexec -i -s CMD

and actual test run in the newly created cmd windows (runs as Local System):

path_to_nuget\nuget.exe restore "path_to_solution\theSolution.sln"
Alexei - check Codidact
  • 22,016
  • 16
  • 145
  • 164
9

In my case, it was that I was unknowingly logged out of my work account altogether. Logging back into my visual studio account resolved it.

DrDoomPDX
  • 282
  • 3
  • 12
  • 3
    This was it for me, i changed my password. VS2022 looked like i was still logged in. Clicking my profile showed that i had to re-enter my credentials – Joris Mathijssen Sep 29 '22 at 10:12
  • 1
    This was it for me as well :) – Tikki Oct 14 '22 at 08:46
  • Yep I tried all of the above. Turned out I was just not logged in to Visual Studio on my new PC. (Many of the higher upvoted answers are from years ago and may not even be issues anymore). – MGOwen Nov 29 '22 at 00:10
7

Simple :

  1. Close VS2019
  2. Go to C:\Users\you\AppData\Roaming\NuGet
  3. Delete the file NuGet.Config
  4. Relaunch VS2019

You're good to go !

Hashka
  • 395
  • 3
  • 10
6

I had a similar issue trying to connect to my private TFS server instead of the public NuGet API server. For some reason I had an issue between the AD server and the TFS server so that it would always return a 401. The NuGet config article shows that you can add your AD username and password to the config file like so:

  <packageSourceCredentials>
      <vstsfeed>
          <add key="Username" value="yourname@company.com" />
          <add key="Password" value="this is an encrypted password" >
          <!-- add key="ClearTextPassword" value="not recommended password" -->
      </vstsfeed>
  </packageSourceCredentials>

This is not quite an ideal solution, more of a temporary one until I can figure out what the problem is with the AD server, but this should do it.

Hydromast
  • 280
  • 3
  • 10
  • How did you encrypt the password? – theonlygusti Mar 12 '21 at 11:25
  • @theonlygusti Use the -password operation and output it on a config location of your choice. See: https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-sources – Hydromast Mar 26 '21 at 06:47
  • 2
    This did the trick for me. In my case I had to use uncomment 'ClearTextPassword' and comment out the 'Password' line. – Eternal21 Mar 21 '22 at 19:30
  • 2
    For anyone wanting to set their credentials, instead of editing the config manually, use NuGet to set it nuget.exe' sources add -name 'My Packages' -source 'https://pkgs.dev.azure.com/myorg/myid/_packaging/mypackages/nuget/v3/index.json' -username '.' -password '' – Jules Clements Oct 19 '22 at 22:44
6

In my case, the problem was that I was building on an older Win7 virtual machine.

I found this fix from https://github.com/NuGet/NuGetGallery/issues/8176#issuecomment-683923724 :

nuget.org started enforcing the use of TLS 1.2 (and dropped support for TLS 1.1 and 1.0) earlier this year. Windows 7 has TLS 1.2 disabled by default (check the DisabledByDefault value under HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client in your registry). To enable the support, please make sure you have an update (*) installed and switch the support on:

reg add HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v DisabledByDefault /t REG_DWORD /d 0 /f /reg:32
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v DisabledByDefault /t REG_DWORD /d 0 /f /reg:64
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v Enabled /t REG_DWORD /d 1 /f /reg:32
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v Enabled /t REG_DWORD /d 1 /f /reg:64

The (*) update referred to was Microsoft kb3140245: Update for Windows 7 (KB3140245)

I installed the update, rebooted (as requested by the update), added those registry keys, and then Nuget worked fine.

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
  • https://improveandrepeat.com/2019/10/how-to-activate-tls-1-2-on-windows-server-2008-r2-and-iis-7-5/ – GregC Jan 14 '21 at 05:20
  • https://knowledge.digicert.com/quovadis/ssl-certificates/ssl-general-topics/how-to-enable-tls-1_2-on-windows-server-2008-r2.html – GregC Jan 14 '21 at 05:20
  • https://devblogs.microsoft.com/nuget/deprecating-tls-1-0-and-1-1-on-nuget-org-stage-1/ – GregC Jan 14 '21 at 05:20
4

One of your nuget sources may be unreachable.

At the moment of writing, AspNetCore (https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json) seems to have an expired certificate or have been removed entirely.

Can't access the JSON file

Simply removing the nuget source from your settings should solve this issue

Removing Nuget Source from Visual Studio

Prince Owen
  • 1,225
  • 12
  • 20
3

The error can be caused by just temporary network issue, and disappear, if try again.

Michael Freidgeim
  • 26,542
  • 16
  • 152
  • 170
3

Something may have change your proxy setting, like Fiddler. Close Fiddler, then close Visual Studio and open it again.

Sylvain Rodrigue
  • 4,751
  • 5
  • 53
  • 67
  • 1
    Thanks! Turning off Fiddler Everywhere solved it for me when Docker build wouldn't restore nugets due to TLS problem on a Mac. Saved my day. – SofterThoughts Sep 24 '20 at 09:17
3

If you are getting this error, but you don't have a proxy server, you can go to

%userprofile%\AppData\Roaming\NuGet\NuGet.Config

And comment this lines:

<config>
     <!-- Proxy settings -->
     <add key="http_proxy" value="host" />
     <add key="http_proxy.user" value="username" />
     <add key="http_proxy.password" value="encrypted_password" />
</config>

It worked for me because I was getting that error, but I don't have a proxy server.

RJFalconer
  • 10,890
  • 5
  • 51
  • 66
Marlon Adarme
  • 357
  • 4
  • 15
3

It is worth noting that there was a bug with .net core SSL authentication that could cause this. Disabling their latest networking stack implementation, solved this issue for me.

You can set this permanently or just launch your app using:

DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0 dotnet ...
firetiger77
  • 351
  • 3
  • 9
3

In my case it is happened because I don’t have internet connection and it is trying to scaffolding

hosam hemaily
  • 412
  • 5
  • 17
3

I was using an older version of Nuget on VS2010, where it defaults to TLS 1.0 here it can be fixed by changing the default TLS version used by .Net framework which is configured in Registry keys

reg add HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 /v SystemDefaultTlsVersions /t REG_DWORD /d 1 /f /reg:64

reg add HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 /v SystemDefaultTlsVersions /t REG_DWORD /d 1 /f /reg:32

FYI

NuGet.org will permanently remove support for TLS 1.0 and 1.1 on June 15th. Please ensure that your systems use TLS 1.2.

You can refer to this link for info on TLS 1.2 support

  • This was me too, except I'm using the latest version of Visual Studio 2019 (16.11.3). I have copies of nuget.exe scattered all over my system and I expect that one of them is on my PATH and is older. – Cory Grimster Sep 29 '21 at 20:36
3

If you are a Windows user, you may either remove or update your credentials in Credential Manager.

In Windows 10, go to the below path:

Control Panel → All Control Panel Items → Credential Manager

Or search for "credential manager" in your "Search Windows" section in the Start menu.

Then from the Credential Manager, select "Windows Credentials".

Credential Manager will show many items including your outlook and GitHub repository under "Generic credentials"

You click on the drop down arrow on the right side of your Git: and it will show options to edit and remove. If you remove, the credential popup will come next time when you fetch or pull. Or you can directly edit the credentials there.

David Castro
  • 1,773
  • 21
  • 21
3

I spent a day on this and tried everything here. For me it was that I didn't update my password in Visual Studio!

I had changed my work Microsoft account password last week or so, I also use that account to login to visual studio, however I wasn't prompted to update it and was not logged out of Visual Studio, it remained logged in. When I clicked on my initials in the top right of visual studio > Account settings > under All Accounts the work account had yellow exclamation triangle warning sign next to it, updated the new password, then updated some packages, dotnet restore, cleaned & rebuilt and the errors are gone.

imsan
  • 359
  • 4
  • 17
2

Some development environment may not be using neither a browser nor a proxy.

One solution would downloading the package from nugget such as the https://dotnet.myget.org/F/dotnet-core/api/v3/index.json to a shared directory then execute the following:

dotnet add package Microsoft.AspNetCore.StaticFiles -s "shared drive:\index.json"

I hope that works for you.  

Phani Kumar M
  • 4,564
  • 1
  • 14
  • 26
2

I had this error and then I realized I was logged in with my personal Microsoft account instead of my work account.

Hope this helps.

2

I was trying to add an Azure Artifacts NuGet source.

I followed Microsoft's instructions here, with one critical oversight.

I forgot to replace /v3/index.json with /v2.

enter image description here

Jim G.
  • 15,141
  • 22
  • 103
  • 166
2
nuget restore 

and

msbuild /t:restore

both didn't work for me with same error. But

dotnet restore 

worked perfect. Try that

Vladimir Zotov
  • 571
  • 6
  • 16
  • `dotnet restore --interactive` worked for me on linux. I am not sure what should that `--interactive` do but it was not interacting at all, just worked. – andrej Aug 04 '21 at 11:47
2

Tested on Windows 7

Step1 : Open Command window (run cmd) Step 2: Run the following commands to enable TLS 1.2 support if it is disabled (adding REGISTRY Entries):

reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v DisabledByDefault /t REG_DWORD /d 0 /f /reg:32
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v DisabledByDefault /t REG_DWORD /d 0 /f /reg:64
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v Enabled /t REG_DWORD /d 1 /f /reg:32
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v Enabled /t REG_DWORD /d 1 /f /reg:64

Rami A.
  • 10,302
  • 4
  • 44
  • 87
2

In my case i lost the connection with Git. I just added the connection again and it worked!:

Connection to Team Explorer

Lemraj
  • 279
  • 3
  • 4
2

I have a couple Windows 2016 Servers where Visual Studio couldn't connect to NuGet. After trying virtually every other suggested fix (registry changes, Visual Studio/NuGet related cache clearing or file/config changes), the below is what resolved it for us.

We have a Group Policy (GPO) with the ciphers set and I added these ciphers to our GPO cipher list for it to work.

TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256

https://github.com/NuGet/Announcements/issues/60

mindmischief
  • 271
  • 1
  • 12
2

OK I tried all the answers above and hope my registry is not now hosed. But this appears to have fixed it for me:

https://learn.microsoft.com/en-us/answers/questions/959588/visual-studio-2022-won39t-connect-to-nuget.html

enter image description here

Add this: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384

To the comma-separated string in this:

HKLM\SOFTWARE\Policies\Microsoft\Cryptography\Configuration\SSL\00010002

I hope this helps the next person who hope to make a fun quick Saturday morning proof-of-concept, and then winds up spending 3 hours searching for a fix!!!

Daniel Williams
  • 8,912
  • 15
  • 68
  • 107
1

In support of the answer provided by @Eddie Chen (here) I had to add http_proxy setting to following file as well:

C:\Windows\system32\config\systemprofile\AppData\Roaming\NuGet\NuGet.Config

<add key="http_proxy" value="http://your_proxy_url:8080" />
jitin14
  • 144
  • 5
1

I was getting this same error while running RUN dotnet restore in my Dockerfile using docker-compose up command in Windows 10.

enter image description here

I have tried all the possible solution provided on the internet and was also keep an eye on this open issue. Finally, after spending more than 8 hours, by following the preceding steps, I was able to fix my issue.

  1. Uninstall Docker from your system
  2. Restart your system
  3. Install Docker from this link. Below is the version of my Docker

    enter image description here

  4. Restart your system

  5. Start Docker for Windows, search Docker in the search bar in Windows. Make sure it is running.

  6. You should also go to Services.msc and make sure the services Docker Engine and Docker for Windows Service are running.

    enter image description here

  7. At last, you must check your Nuget.config file from C:\Users\{Username}\AppData\Roaming\NuGet. For me, the content of that file was as below.

    <?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> </packageSources> <packageRestore> <add key="enabled" value="True" /> <add key="automatic" value="True" /> </packageRestore> <bindingRedirects> <add key="skip" value="False" /> </bindingRedirects> <packageManagement> <add key="format" value="0" /> <add key="disabled" value="False" /> </packageManagement> </configuration>

    Hope this helps.

Community
  • 1
  • 1
Sibeesh Venu
  • 18,755
  • 12
  • 103
  • 140
  • I was also facing the same problem when run docker file in VS code, after spending 4 hours come to know that need to add these two lines in docker files and all well ARG HTTP_PROXY=http://your_proxy:port/ ARG HTTPS_PROXY=http://your_proxy:port/ – Saad Awan Feb 20 '22 at 06:57
1

In my case i had had Fiddler running which had changed my proxy settings

Dooie
  • 1,649
  • 7
  • 30
  • 47
1

I'm using VSO/Azure DevOps.

You can also visit the feed url directly in your browser. You may end up with a response that contains a message like this, which may make your diagnosis a lot quicker:

The user does not have a license for the extension ms.feed.

ps2goat
  • 8,067
  • 1
  • 35
  • 68
  • Yes I've noticed this today as well. Works just fine in normal non- dotnet core projects in VS but it kills an example core project in a docker container (despite it not wanting or needing anything from our corporate Azure DevOps hosted NuGet repo) stone dead. Not quite sure how on earth to fix this without that feed license which isn't going to happen. Surely this has to be a bug since what is the point in a NuGet repo you can't use with core? – Steve Pettifer Mar 06 '19 at 09:52
  • If you aren't using anything from the repo, see if you can remove that source from the NuGet.Config file. We have a build agent with access to the feeds, so it works for us. – ps2goat Mar 06 '19 at 17:06
  • If only I could. I need stuff from that repo sadly (I was mistaken in my original comment otherwise I'd comment out or delete that source in the NuGet config, but that would affect other projects which use it). As it happens it seems that once I (finally) get my MSDN sub assigned to me, my user privilege level in Azure DevOps will increase/be increased and I'll get access to the `package sources` extension which will make this work. Seems a bit silly but there it is. – Steve Pettifer Mar 06 '19 at 22:11
1

In my case, I just restarted the docker and just worked.

Shwe
  • 455
  • 5
  • 11
1

If using Visual Studio 2019, just delete the "defaultproxy" section if you are not using any default proxies in devenv.exe.config. in VS 2017 this section was not present

change

<defaultProxy enabled="true" useDefaultCredentials="true">
    <proxy bypassonlocal="True" proxyaddress="http://<yourproxy:port#>"/>
</defaultProxy>

to

<!--<defaultProxy enabled="true" useDefaultCredentials="true">
    <proxy bypassonlocal="True" proxyaddress="http://<yourproxy:port#>"/>
</defaultProxy>-->

Else provide the appropriate proxy username and password.

Aditya Mishra
  • 311
  • 2
  • 3
1

I had the same error message while scaffolding Identity to my ASP.NET Core MVC project. Since my connection was not behind a proxy, removing/editing proxy configurations didn't make sense. And I didn't want to delete a file or uninstall PMC either. While looking around I realized a "Clear All Nuget Cache(s)" button on Tools --> Options --> NuGet Package Manager --> General. After pressing the button I had to wait for some time for the operation to complete. After that I tried to scaffold the Identity again but it didn't work. Then I decided to restart VS and voila :)

enter image description here

heuristican
  • 294
  • 1
  • 8
1

I had a similar problem while trying to execute Install-Package Modernizr on Visual Studio 2015. I fixed my problem by following the below steps:

  1. Download the package from its online source.
  2. Go to Tools/NuGet Package Manager/Package Manager Settings.
  3. Select Package Sources from the window.
  4. Add a new package source by clicking on the + sign. Enter a name and source location by clicking on ... (triple dot) sign.
  5. Make sure that only the package source that you've just added is checked. Uncheck all the other package sources.
  6. Go to Package Manager Console and type Install-Package Modernizr.
  7. Visual Studio 2015 installs the package automatically and creates Scripts and packages folders in your root folder.

I hope the same solution works while installing other packages, too.

Ramil Aliyev 007
  • 4,437
  • 2
  • 31
  • 47
1

I tried many of the listed answers here but these didn't resolve the problem. In the end, I had to go to the credential manager in Windows and delete the VSCredentials_xxx entry under "Windows Credentials" and restart Visual Studio 2019.

After that - on the next VS start - VS finally asked me for my proxy credentials - and after entering them, access to the internet for Visual Studio worked.

(It seemed that VS did store my initially given proxy credentials long ago - but because in our company they have password change after 3 months enforced - the credentials were no longer valid.)

John Ranger
  • 541
  • 5
  • 18
1

I fixed this issue by installing IISCrypto and running this on command line:

IISCryptoCli.exe /template default /reboot
twasbrillig
  • 17,084
  • 9
  • 43
  • 67
1

I deleted everything in %localappdata%/Nuget and cleared the NuGets cache.

dotnet nuget locals all --clear

After restart, Visual studio 2022 restored my packages.

K. B.
  • 3,342
  • 3
  • 19
  • 32
1

If anyone is still having trouble and the NuGet answers are not working. The following answer worked for me (a company DevOps Azure hosted TFS): sign in and out of teams foundation. TFS and VS both reported as signed in but turns that was not the case. Had to resign in -- same symptoms as described by OP. See this answer for more details.

petrosmm
  • 528
  • 9
  • 23
  • 1
    Lol this is so stupid... I cannot for the life of me understand what's the connection between my account and the build agent doing the nuget restore.... I just queued the damn job... but IT WORKED!!! Thanks! – Stefan Balan Apr 04 '23 at 07:53
  • 1
    @StefanBalan Congrats. Just a guess.. the cookie/ticket/auth reports valid but underneath (in some other areas) it is definitely expired and not working in other areas. Our nuget service is internal to our company, so maybe (company/config) was a factor. – petrosmm Apr 05 '23 at 13:21
0

Go to -> Tools -> Extensions and Updates and uninstall NuGet package manager.. restart visual studio and reinstall it.... every thing will set to normal

Kadeer Mughal
  • 101
  • 1
  • 11
0

in my case i had to add the sources in the Visual studio Options->NugetPAckageManager->sources and then restart the visual studio command prompt

lemon
  • 71
  • 1
  • 4
0

Maybe this helps

For me removing the .nuget folder located in C:\Users\YourNameHere fixed the problem.

IvanovAndrew
  • 141
  • 2
  • 5
  • 8
0

Setting of your PC -> Network And Internet Proxy -> Automatic Proxy Setup then set Automatically detect settings to off and clear the Script Address

0

Installing fiddler was causing me similar problem. Uninstalling fiddler and removing the fiddler proxy from the machine.config (from both Framework and Framework64) solved the problem.

Samuel
  • 1,949
  • 4
  • 18
  • 30
0

I couldn't resolve the problem itself, but found a way to install packages.

Just specify nuget.org as a source directly in Package Manager Console.

Update-Package -reinstall -Source nuget.org
Turbcool
  • 84
  • 8
0

I encountered this error when trying to set up NuGet packages inside locally hosted Gitlab instance. The error indicated 401 Unauthorized code. The solution was removing offending source with:

nuget source Remove -Name SOURCE_NAME

And then adding the same source, but this time specifying the username and password in the command:

nuget source Add -Name SOURCE_NAME -Source SOURCE_URL -UserName GITLAB_DEPLOY_TOKEN_USERNAME -Password GITLAB_DEPLOY_TOKEN
Eternal21
  • 4,190
  • 2
  • 48
  • 63
0

Disable your anti-virus application. In my case, AVG was preventing accessing nuget.org

Alper Ebicoglu
  • 8,884
  • 1
  • 49
  • 55
0

I had to run dotnet restore in command prompt from the folder where the .sln is located, which worked successfully (while VS failed restoring the nuget packages). After this, I was able to list the Installed packages under Visual Studio at least, but "Updates" was still failing to load.

Peter PitLock
  • 1,823
  • 7
  • 34
  • 71
0

The answers that say to just delete Nuget.Config won't work if you're using a custom feed. If you're using a custom feed, you need to edit the Nuget.Config file to point to the index of your custom feed.

Ethan Seal
  • 31
  • 8
0

In my case, it was due to a change in my network configuration. The ultimate solution is to restart your computer.

acmoune
  • 2,981
  • 3
  • 24
  • 41
-1

It seems Nuget still uses the proxy script address (for our VPN) even though the proxy settings are disabled. I removed the script address and it works.

enter image description here

d.i.joe
  • 606
  • 9
  • 22
-1

If you are behind a company proxy and on Mac, just make sure your http/https checkboxes are checked and applied.

Mr. Mayonnaise
  • 159
  • 1
  • 2
  • 13
-2
  1. go to %appdata%\NuGet\NuGet.config

  2. Modify this line:

    <packageSources>
        <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
        <add key="Package source" value="https://api.nuget.org/v3/index.json" />
    </packageSources>
    
Tomer Shetah
  • 8,413
  • 7
  • 27
  • 35
Vinod John
  • 69
  • 1
  • 2
  • 11