336

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.

8
  • Possible duplicate of VS2015 nuget package manager not finding packages Commented Dec 16, 2016 at 13:29
  • Do you have proxy configured on your machine? Or "http_proxy" variable configured in environment variable? Commented Dec 20, 2016 at 2: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. Commented Dec 20, 2016 at 10:30
  • 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:port Commented Feb 20, 2022 at 6:58
  • 3
    Not sure it's worth a separate answer, but my problem was that my jfrog token had expired. Didn't quite notice since other solutions built and I could actually log into jfrog itself no problem. Generated a new identity token, updated my environment variables accordingly, restarted Visual Studio, and it all works. Commented Sep 30, 2024 at 9:11

59 Answers 59

1
2
2

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

dotnet nuget locals all --clear 

After restart, Visual studio 2022 restored my packages.

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

Comments

2

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.

2 Comments

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

Comments

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

Comments

1

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

Comments

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.

3 Comments

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

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

Comments

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.

1 Comment

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

Comments

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

Comments

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.

Comments

1

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

IISCryptoCli.exe /template default /reboot 

1 Comment

Running IIS crypto and setting everything back to "best practice" solved it for me too
1

I got this error when calling dotnet restore without any further error message. I usually use a VPN with a proxy but I wanted to do the restore without the VPN. In my case I had to set the environment variables HTTP_PROXY and HTTPS_PROXY to empty (you can do this temporarily inside your CMD/bash). Also use a fresh local nuget.config file like:

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

Then I called dotnet restore --configfile nuget.config. This ensures that no other nuget configs are considered. Usually there is a hierarchy and configs in parent directories or inside your appdata folder are also considered for proxy settings etc.

With all this I could ensure that it worked again.

Comments

0

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

Comments

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

Comments

0

Maybe this helps

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

1 Comment

it screwed up my VS, and all projects ... even the package manager
0

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

Comments

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.

Comments

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 

Comments

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 

Comments

0

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

Comments

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.

Comments

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.

Comments

0

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

Comments

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.

Comments

-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

Comments

-1

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

Comments

-1

My error was

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

Background

I had recently updated the password for my work account. I had re-entered my credentials in Visual Studio 2022, and it showed me signed in. However, this version of VS had a bug that did not update credentials as expected.

Solution

  1. I updated Visual Studio 2022 to version 17.10.4 (This took about 30 minutes.)
  2. I signed in to my work account on VS, re-entering my credentials.
  3. Build succeeded!

Comments

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

1 Comment

I see four lines :O
1
2

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.