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.
This question is related to
.net
visual-studio
nuget
In my case, the problem was that I was building on a, older virtual machine which was based on Win7.
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 underHKLM\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.
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.
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
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" />
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"
Maybe this helps
For me removing the .nuget folder located in C:\Users\YourNameHere fixed the problem.
Setting of your PC -> Network And Internet Proxy -> Automatic Proxy Setup then set Automatically detect settings to off and clear the Script Address
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.
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.
Deleting the %AppData%\NuGet\NuGet.Config and restarting VS2019 worked for me.
Similar to https://github.com/NuGet/Home/issues/3281
I was getting this same error while running RUN dotnet restore
in my Dockerfile
using docker-compose up
command in Windows 10
.
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.
Docker
from your systemInstall Docker
from this link. Below is the version of my Docker
Restart your system
Start Docker for Windows, search Docker
in the search bar in Windows. Make sure it is running.
You should also go to Services.msc
and make sure the services Docker Engine
and Docker for Windows Service
are running.
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.
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.
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:
Install-Package Modernizr
.I hope the same solution works while installing other packages, too.
In my case, I just restarted the docker and just worked.
I have resolved this issue using below steps
Click on run search this %APPDATA%\NuGet\NuGet.config.
Open the setting and add this http_proxy keyin NuGet.config.
Then you will able install the BouncyCastle.Crypto.dll in your application.
Thank you! Responses are welcome if you help this answer.
nuget restore
and
msbuild /t:restore
both didn't work for me with same error. But
dotnet restore
worked perfect. Try that
In my case it is happened because I don’t have internet connection and it is trying to scaffolding
In my case i had had Fiddler running which had changed my proxy settings
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
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.
Go to
Settings ( Global Settings of your PC ) > Network and Internet > Proxy > Automatic Proxy Setup > and set Automatically detect settings to off.
go to %appdata%\NuGet\NuGet.config
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>
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
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).
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.
The error can be caused by just temporary network issue, and disappear, if try again.
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 ...
Make sure docker is running in your local machine. build command will work but its required running docker to get network data.
I think it will help.
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.
in my case i had to add the sources in the Visual studio Options->NugetPAckageManager->sources and then restart the visual studio command prompt
If you are behind a company proxy and on Mac, just make sure your http/https checkboxes are checked and applied.
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
.
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 :)
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.
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
Something may have change your proxy setting, like Fiddler. Close Fiddler, then close Visual Studio and open it again.
Go to -> Tools -> Extensions and Updates and uninstall NuGet package manager.. restart visual studio and reinstall it.... every thing will set to normal
Source: Stackoverflow.com