7

This is not really a Duplicate to this question as the answers provided are not working and I am using Windows-7 on a MacBook using Bootcamp.

I am getting the following error while trying to search any package in the Nuget Package Manager:

Severity Code Description Project File Line Suppression State Error [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 underlying connection was closed: An unexpected error occurred on a send. Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. An existing connection was forcibly closed by the remote host

My NuGet Config File (%appdata%/nuget):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>
4
  • Can you even reach that URL on your windows install? Commented Apr 18, 2022 at 14:02
  • @mxmissile Yes, I am able to access thw URL in a browser Commented Apr 18, 2022 at 14:42
  • @skm I have the same issue, but I'm using VS on VirtualBox Win 7 VM. Did you solve your problem? Commented May 5, 2022 at 13:24
  • @skm this answer helped me stackoverflow.com/a/65424896/7991817 Commented May 5, 2022 at 13:57

4 Answers 4

6

Well.. let me try if this can save your day. I faced the same issue, and I tried everything mentioned in this post and few related posts (started 5-6 years ago) mentioned below, but unfortunately nothing worked.. until I had a trick that solved my problem. This could be a temp solution but could save hours if this glitch is caused by some Windows update or network policy or Anti Virus and what not!

My situation: One of my few development PCs (Win11, Win10) with VS 2022 (17.7.5) started showing this error when building the solution from Visual Studio:

[nuget] unable to load the service index for source https://api.nuget.org/v3/index.json. an error occurred while sending the request. the remote name could not be resolved: 'api.nuget.org'

Interestingly the same was working on other PCs. I spent many hours debugging and following the below threads. Did many reboots, restarts.. nothing helped. Even I tried downloading VS 2019 to confirm and the same issue showed up.

C:\Windows\System32> ping api.nuget.org
Ping request could not find host api.nuget.org. Please check the name and try again.

So I realized this is a network thing that messed up on one of my PCs and it was not able to resolve the DNS for api.nuget.org. I'm coding for more than 2 decades but still the IP config and other networking stuff freaks me out!

My Solution: I ran this on a good PC (command prompt):

C:\Windows\System32>ping api.nuget.org
Pinging part-0010.t-0009.t-msedge.net [13.107.246.38] with 32 bytes of data:
Reply from 13.107.246.38: bytes=32 time=71ms TTL=57
Reply from 13.107.246.38: bytes=32 time=19ms TTL=57
...

and added this to the hosts file on the bad PC (C:\Windows\System32\drivers\etc):

13.107.246.38   api.nuget.org

...and boom!!!

Related posts (I tried all answers and it didn't work for me):

Sign up to request clarification or add additional context in comments.

1 Comment

Wow, you save me a lot of time and effort. IDK why, all network commands related to dotnet start not working anymore and with your post I can work again :)
5

Nuget.org started enforcing the use of TLS 1.2 (and dropped support for TLS 1.1 and 1.0). 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

1 Comment

Updating VS fixed it for me
0

For me rebuilding the solution or the project worked.

Comments

0

Try

dotnet nuget locals all --clear

This worked for me in 2025.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.