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

.NetVisual StudioNuget

.Net Problem Overview


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.

This question is not a duplicate. The other answers don't solve my problem.

.Net Solutions


Solution 1 - .Net

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

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

Solution 2 - .Net

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

Solution 3 - .Net

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

}

Solution 4 - .Net

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

Solution 5 - .Net

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"

Solution 6 - .Net

Go to

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

Solution 7 - .Net

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

Solution 8 - .Net

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 !

Solution 9 - .Net

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.

Solution 10 - .Net

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.

Solution 11 - .Net

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

Solution 12 - .Net

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

Solution 13 - .Net

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

Solution 14 - .Net

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

Solution 15 - .Net

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

Solution 16 - .Net

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

Solution 17 - .Net

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

Solution 18 - .Net

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.

Solution 19 - .Net

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.  

Solution 20 - .Net

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

Solution 21 - .Net

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.

Solution 22 - .Net

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

Solution 23 - .Net

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.

Solution 24 - .Net

nuget restore 

and

msbuild /t:restore

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

dotnet restore 

worked perfect. Try that

Solution 25 - .Net

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.

Solution 26 - .Net

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

"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

Solution 27 - .Net

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" />

Solution 28 - .Net

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

  1. Restart your system

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

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

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

Solution 29 - .Net

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

Solution 30 - .Net

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

Solution 31 - .Net

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.

Solution 32 - .Net

Maybe this helps

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

Solution 33 - .Net

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

Solution 34 - .Net

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

Solution 35 - .Net

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

Solution 36 - .Net

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

Solution 37 - .Net

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.

Solution 38 - .Net

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

Solution 39 - .Net

  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>
    

Solution 40 - .Net

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

Solution 41 - .Net

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

Solution 42 - .Net

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.

Solution 43 - .Net

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

Connection to Team Explorer

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDarthVaderView Question on Stackoverflow
Solution 1 - .NetjanonimusView Answer on Stackoverflow
Solution 2 - .NetEddie Chen - MSFTView Answer on Stackoverflow
Solution 3 - .NetHarshaView Answer on Stackoverflow
Solution 4 - .NetShradha ShilvantView Answer on Stackoverflow
Solution 5 - .NetAlexei - check CodidactView Answer on Stackoverflow
Solution 6 - .NetVISHAL TANKView Answer on Stackoverflow
Solution 7 - .NetJonathan ChowView Answer on Stackoverflow
Solution 8 - .NetHashkaView Answer on Stackoverflow
Solution 9 - .NetHydromastView Answer on Stackoverflow
Solution 10 - .NetMarlon AdarmeView Answer on Stackoverflow
Solution 11 - .Netfiretiger77View Answer on Stackoverflow
Solution 12 - .Nethosam hemailyView Answer on Stackoverflow
Solution 13 - .NetMichael FreidgeimView Answer on Stackoverflow
Solution 14 - .NetSylvain RodrigueView Answer on Stackoverflow
Solution 15 - .NetSahil GuleriaView Answer on Stackoverflow
Solution 16 - .NetPrince OwenView Answer on Stackoverflow
Solution 17 - .NetheuristicanView Answer on Stackoverflow
Solution 18 - .NetStayOnTargetView Answer on Stackoverflow
Solution 19 - .NetCharles MosesView Answer on Stackoverflow
Solution 20 - .NetDooieView Answer on Stackoverflow
Solution 21 - .Netps2goatView Answer on Stackoverflow
Solution 22 - .NetShweView Answer on Stackoverflow
Solution 23 - .NetAditya MishraView Answer on Stackoverflow
Solution 24 - .NetVladimir ZotovView Answer on Stackoverflow
Solution 25 - .Netİlker SevinçView Answer on Stackoverflow
Solution 26 - .Netuser2274515View Answer on Stackoverflow
Solution 27 - .Netjitin14View Answer on Stackoverflow
Solution 28 - .NetSibeesh VenuView Answer on Stackoverflow
Solution 29 - .NetKadeer MughalView Answer on Stackoverflow
Solution 30 - .NetlemonView Answer on Stackoverflow
Solution 31 - .NetMark InfantinoView Answer on Stackoverflow
Solution 32 - .NetIvanovAndrewView Answer on Stackoverflow
Solution 33 - .NetJim G.View Answer on Stackoverflow
Solution 34 - .Netd.i.joeView Answer on Stackoverflow
Solution 35 - .NetMr. MayonnaiseView Answer on Stackoverflow
Solution 36 - .NetArun Kumar YaduView Answer on Stackoverflow
Solution 37 - .NetSamuelView Answer on Stackoverflow
Solution 38 - .NetTurbcoolView Answer on Stackoverflow
Solution 39 - .NetVinod JohnView Answer on Stackoverflow
Solution 40 - .NetEternal21View Answer on Stackoverflow
Solution 41 - .NetJohn RangerView Answer on Stackoverflow
Solution 42 - .NetDavid CastroView Answer on Stackoverflow
Solution 43 - .NetLemrajView Answer on Stackoverflow