Nuget connection attempt failed "Unable to load the service index for source"
Asked Answered
B

56

288

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.

Betony answered 16/12, 2016 at 13:24 Comment(10)
Possible duplicate of VS2015 nuget package manager not finding packagesWolford
Since you have post the same issue on another thread (https://mcmap.net/q/109854/-nuget-not-connecting-duplicate), please continue this issue on your previous thread. And I also will follow this issue on your previous thread.Durative
Do you have proxy configured on your machine? Or "http_proxy" variable configured in environment variable?Jacky
Yes I have multiple proxies running on my machine. When I installed fiddler. I was able to access to nuget. I have corp proxy.Betony
@DarthVader, if Eddie's reply help you resolve this issue, would you please mark it as the answer? Have a nice day:)Lung
I just restarted my Visual studio and it worked!Basinet
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.Novation
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.Amidase
For me, the exact same nuget API URL works within Visual Studio but not on the command line (ie for .NET 5)Maier
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=your_proxy:port ARG HTTPS_PROXY=your_proxy:portDeandre
J
58

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

Jacky answered 21/12, 2016 at 8:43 Comment(6)
For me it was that I had a http_proxy environment variable set up that was wrong.Ogbomosho
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?Flawed
The config file should be present at %AppData%\NuGet\ or C:\Users\WindowsLoginName\AppData\Roaming\NuGetPunkah
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?Harkness
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.Whichever
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 tellMaier
F
214

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

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

Febrile answered 23/6, 2020 at 23:55 Comment(11)
I am using VS 2017, works for me too.Shortwinded
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.Handler
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).Catawba
if this doesn't work for you, just make sure \Roaming isn't already part of the %APPDATA% path.Bubbly
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 systemBarcellona
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á.Collate
I have no idea why I have a source "packagesource" and who puts it there, but your answer solved the issue for me!Cysticercus
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.Randolph
What should be done by MacOS users in this case?Tollefson
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.Fun
This solution also worked for me when I was experiencing an issue with installs getting stuck in JetBrains Rider, with the installer stuck on GET https://api.nuget.org/v3/vulnerability.update.json. I also deleting everything in %AppData%\Local\NuGet\v3-cacheLugworm
J
58

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

Jacky answered 21/12, 2016 at 8:43 Comment(6)
For me it was that I had a http_proxy environment variable set up that was wrong.Ogbomosho
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?Flawed
The config file should be present at %AppData%\NuGet\ or C:\Users\WindowsLoginName\AppData\Roaming\NuGetPunkah
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?Harkness
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.Whichever
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 tellMaier
P
46

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

Phytogeography answered 3/10, 2018 at 10:47 Comment(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.Obnoxious
you dont need to remove it you can disable itStockpile
Also be sure to look at what options may be specified within the key. I accidentally replaced the default NuGet URL with a local repository and it didn't work because it retained the 'protocolVersion="3"' decoration which was incompatible with the local repository.Asco
L
37

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);

}
Lambaste answered 14/11, 2019 at 7:43 Comment(9)
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 api.nuget.org/v3/index.json. [nuget.org] Unable to load the service index for source api.nuget.org/v3/index.json. An error occurred while sending the request. The request was aborted: Could not create SSL/TLS secure channel".Iorio
It worked. But why? What could cause this problem? How did something dare to change the registry like that? And for what?Hilarity
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.Lambaste
This trick actually solved the problem and my other .NET apps as well!Benelux
I have same problem as OP. In my Windows 10 box registry, Protocols folder is empty (no TLS 1.3 option nor anything inside).Broadcasting
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ÁlvarezArbuthnot
For those that say the TLS 1.3 keys dont exist. Just create them. It will work after thisWinker
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.Solfa
Did you mean DisabledByDefault property (instead of key)?Cameleer
C
30

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) }"
Churchy answered 25/10, 2022 at 15:0 Comment(5)
That was actually my case. I had to login into visual studioAlliance
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!Mechanism
I used jet brains rider, this solution actually worked for me.Urogenous
This actually work for dotnet tool restore --interactive. Just install the nuget plugin artifacts-credproviderVega
The hint for the artifacts-credprovider just saved me from some major headache!Washy
F
17

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).
Federation answered 1/7, 2020 at 15:15 Comment(3)
This is what (finally) helped me.Serpent
This one fixed it for me on OSX. Running dotnet build or dotnet restore showed the error. Installing the Azure Artifacts Credential and then using dotnet restore --interactive made it work again.Philbrick
This fixed it for me after numerous trial and error attempts with other solutions. I downloaded the latest Microsoft.NuGet.CredentialProvider.zip from that GitHub link and replaced the existing files in %UserProfile%/.nuget/plugins/ . Whatever this did, it resolved the issue.Scapular
P
16

Go to

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

Pamphylia answered 30/9, 2017 at 6:43 Comment(2)
This is the only thing that worked for me as well 2022.Outwit
This worked with VS 2022 Pro, on a new Windows 11 machine (did not have this issue on win10). No other changes madeKandicekandinsky
N
14

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"
Newcomen answered 31/12, 2018 at 12:23 Comment(1)
thank you, I added the proxy tag and my problem is solvedAlgonkian
S
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.

Sapiential answered 30/8, 2022 at 12:48 Comment(1)
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 credentialsKwakiutl
A
8

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 !

Alignment answered 22/9, 2021 at 14:20 Comment(2)
or %AppData%\NuGetHennahane
duplicate of https://mcmap.net/q/107442/-nuget-connection-attempt-failed-quot-unable-to-load-the-service-index-for-source-quotCameleer
E
7

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="[email protected]" />
          <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.

Extol answered 8/11, 2019 at 16:10 Comment(4)
How did you encrypt the password?Fischer
@Fischer Use the -password operation and output it on a config location of your choice. See: learn.microsoft.com/en-us/nuget/reference/cli-reference/…Extol
This did the trick for me. In my case I had to use uncomment 'ClearTextPassword' and comment out the 'Password' line.Goltz
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 'pkgs.dev.azure.com/myorg/myid/_packaging/mypackages/nuget/v3/…' -username '.' -password '<personal access token>'Piscine
A
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.

Azaria answered 23/12, 2020 at 13:13 Comment(3)
improveandrepeat.com/2019/10/…Lepus
knowledge.digicert.com/quovadis/ssl-certificates/…Lepus
devblogs.microsoft.com/nuget/…Lepus
G
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

Garda answered 20/6, 2021 at 7:16 Comment(0)
G
3

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.  

Gunny answered 20/9, 2017 at 0:47 Comment(0)
M
3

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

Moulin answered 16/11, 2017 at 1:55 Comment(0)
P
3

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

Prothesis answered 1/6, 2018 at 22:36 Comment(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.Pierre
R
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.

Reames answered 23/3, 2019 at 15:9 Comment(2)
How did you encrypt the password?Fischer
I did not encrypt the password. I didn't have one, there was no proxy.Reames
A
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 ...
Accede answered 11/9, 2019 at 17:59 Comment(0)
A
3

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

Artless answered 29/10, 2019 at 9:43 Comment(1)
Same here. I was offline for w while and the same issue appeared.Disguise
T
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

Tso answered 17/6, 2020 at 5:33 Comment(1)
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.Hardware
B
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.

Belden answered 6/1, 2022 at 19:15 Comment(1)
I'm tempted to add this as an answer, but it might be more useful as a comment here. Should I do both? This was my problem, but I have a unique scenario where I'm running VS and dotnet/nuget.exe as a different user than my normal windows login. I had to run a terminal as that user and load the credential manager differently: rundll32.exe keymgr.dll, KRShowKeyMgr I found this here: top-password.com/blog/open-credential-manager-in-windows I had some bad credentials stored in there that were interfering with things.Mernamero
S
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.

Speechmaking answered 19/8, 2022 at 16:35 Comment(0)
D
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.

Depraved answered 3/6, 2019 at 14:49 Comment(2)
Thanks, sometimes it's too easy :)Pauper
I was logged in to the correct account, but VS wanted me to re-enter my credentials. So another potential easy fix in the same vein.Resplendent
M
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

Monoacid answered 11/2, 2020 at 15:59 Comment(0)
I
2
nuget restore 

and

msbuild /t:restore

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

dotnet restore 

worked perfect. Try that

Indistinct answered 2/10, 2020 at 5:54 Comment(1)
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.Mo
R
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
Ruttger answered 17/4, 2021 at 10:3 Comment(0)
P
2

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.)

Palladous answered 21/5, 2021 at 5:24 Comment(0)
S
2

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

Connection to Team Explorer

Sidesaddle answered 24/1, 2022 at 15:37 Comment(2)
What has Git got to do with it?Ancient
I think it's because we also use our own nuget pacakges. We have some packages in our artifacts (Azure DevOps)Sidesaddle
S
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

Sadden answered 9/8, 2022 at 21:0 Comment(0)
S
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!!!

Solfa answered 13/8, 2022 at 20:34 Comment(1)
Do you add this as a key? String value? dword?Almire
C
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" />
Cannon answered 17/11, 2017 at 2:43 Comment(0)
U
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.

Unreliable answered 21/7, 2018 at 13:21 Comment(1)
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=your_proxy:port ARG HTTPS_PROXY=your_proxy:portDeandre
W
1

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

Wheeling answered 4/2, 2019 at 13:6 Comment(0)
B
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.

Brilliantine answered 4/3, 2019 at 18:7 Comment(3)
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?Inappreciative
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.Brilliantine
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.Inappreciative
B
1

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

Baedeker answered 7/3, 2019 at 15:48 Comment(0)
A
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.

Anisomerous answered 5/2, 2020 at 18:56 Comment(0)
G
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

Geniagenial answered 12/9, 2020 at 23:37 Comment(0)
D
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.

Deepfreeze answered 25/2, 2021 at 6:9 Comment(0)
A
1

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

IISCryptoCli.exe /template default /reboot
Adapt answered 9/6, 2022 at 23:14 Comment(1)
Running IIS crypto and setting everything back to "best practice" solved it for me tooFossilize
D
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.

Devora answered 15/9, 2022 at 13:17 Comment(0)
J
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.

Jampan answered 14/10, 2022 at 16:20 Comment(2)
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!Ayacucho
@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.Jampan
L
0

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

Levitate answered 1/1, 2019 at 12:19 Comment(0)
S
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

Shalloon answered 9/4, 2019 at 18:39 Comment(0)
C
0

Maybe this helps

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

Chouest answered 16/9, 2019 at 11:14 Comment(1)
it screwed up my VS, and all projects ... even the package managerRocketeer
T
0

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

Tortoni answered 12/4, 2020 at 7:40 Comment(0)
S
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.

Sideshow answered 3/5, 2020 at 13:31 Comment(0)
B
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
Brawl answered 18/12, 2020 at 6:25 Comment(0)
G
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
Goltz answered 3/2, 2021 at 21:7 Comment(0)
S
0

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

Samuella answered 7/6, 2022 at 17:41 Comment(0)
U
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.

Unshaped answered 31/8, 2022 at 6:36 Comment(0)
A
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.

Avitzur answered 11/10, 2022 at 17:57 Comment(0)
C
0

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

Careaga answered 10/2, 2023 at 9:34 Comment(0)
M
0

I am adding this as an answer because I have a unique scenario someone else might encounter as well: I'm running Visual Studio and thus the dotnet/nuget.exe restore as a different user than my normal windows login. I had to run a terminal as that user and load the credential manager differently:

rundll32.exe keymgr.dll, KRShowKeyMgr

I found this here: https://www.top-password.com/blog/open-credential-manager-in-windows/

I had some bad credentials stored in there that were interfering with things. Once I removed those, that is when I was finally able to restore nuget packages on the command line, and then in Visual Studio.

Also, we use an on premise Azure Devops server, so even the Azure Credential Manager wouldn't work for me, though that was a potential fix as well, remembering to install the plugins into the other user's profile .nuget plugins. That might work for others if they're encountering this problem with a cloud devops setup.

Mernamero answered 4/1 at 15:34 Comment(0)
S
-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

Skidproof answered 27/3, 2020 at 5:9 Comment(0)
J
-1

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

Joletta answered 6/4, 2020 at 22:24 Comment(0)
L
-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>
    
Luing answered 23/12, 2020 at 9:39 Comment(1)
I see four lines :OJunction

© 2022 - 2024 — McMap. All rights reserved.