.net Nuget 连接尝试失败“无法加载源的服务索引”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41185443/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Nuget connection attempt failed "Unable to load the service index for source"
提问by DarthVader
While trying to connect to Nuget, getting the error below and then I am unable to connect:
尝试连接到 Nuget 时,出现以下错误,然后我无法连接:
[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
[nuget.org] 无法加载源https://api.nuget.org/v3/index.json的服务索引 。发送请求时发生错误。无法连接到远程服务器连接尝试失败,因为连接方在一段时间后没有正确响应,或者因为连接的主机没有响应而建立连接失败 68.232.34.200:443
I am able to access to https://api.nuget.org/v3/index.jsonon my browser.
我可以https://api.nuget.org/v3/index.json在我的浏览器上访问。
It is not a duplicate. The other answers doesn't solve my problem.
它不是重复的。其他答案并不能解决我的问题。
采纳答案by Eddie Chen - MSFT
You need to add proxy settings into Nuget.Config file. Refer to this link for details: Nuget Config Section& Nuget Proxy Settings.
您需要将代理设置添加到 Nuget.Config 文件中。有关详细信息,请参阅此链接:Nuget 配置部分和Nuget 代理设置。
回答by Razi
Open Registry Editor by pressing Win+ Rand type regeditEnter
按Win+打开注册表编辑器R并输入regeditEnter
Navigate to:
导航:
\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client
Change the value of DisabledByDefaultkey 0 to 1
将DisabledByDefault键 0的值更改为 1
Then restart the Visual Studio.
然后重新启动 Visual Studio。
回答by Alexei
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.Configfile which looks like the following:
我在尝试通过 Jenkins 运行 nuget.exe 时偶然发现了这个问题(配置为服务,默认情况下使用本地系统帐户)。我编辑C:\Windows\System32\config\systemprofile\AppData\Roaming\NuGet\NuGet.Config了如下所示的文件:
<?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:
为了测试命令提示符可以通过PSTools启动:
psexec -i -s CMD
and actual test run in the newly created cmd windows (runs as Local System):
并在新创建的 cmd 窗口中实际测试运行(作为本地系统运行):
path_to_nuget\nuget.exe restore "path_to_solution\theSolution.sln"
回答by VISHAL TANK
Go to
去
Settings ( Global Settings of your PC ) > Network and Internet > Proxy > Automatic Proxy Setup > and set Automatically detect settings to off.
设置(PC 的全局设置)> 网络和 Internet > 代理 > 自动代理设置 > 并将自动检测设置设置为关闭。
回答by Shradha Shilvant
I was getting the same error while trying to browse the NuGet Package, to resolve the same followed below step
我在尝试浏览 NuGet 包时遇到相同的错误,以解决以下步骤中的相同问题
1- go to %appdata%\NuGet\NuGet.config
1-去 %appdata%\NuGet\NuGet.config
2- Verify the urls mentioned in that config
2-验证该配置中提到的网址
3- Remove the url which is not required
3-删除不需要的网址
4- Restart visual studio and check
4-重新启动visual studio并检查
回答by firetiger77
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.
值得注意的是,.net 核心 SSL 身份验证存在一个可能导致此问题的错误。禁用他们最新的网络堆栈实现,为我解决了这个问题。
You can set this permanently or just launch your app using:
您可以永久设置此设置,也可以使用以下方法启动您的应用程序:
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0 dotnet ...
回答by hosam hemaily
In my case it is happened because I don't have internet connection and it is trying to scaffolding
就我而言,这是因为我没有互联网连接并且它正在尝试搭建脚手架
回答by Frosteeze
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:
我在尝试连接到我的私有 TFS 服务器而不是公共 NuGet API 服务器时遇到了类似的问题。出于某种原因,我在 AD 服务器和 TFS 服务器之间遇到了问题,因此它始终会返回 401。 NuGet 配置文章显示您可以将 AD 用户名和密码添加到配置文件中,如下所示:
<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.
这不是一个理想的解决方案,在我弄清楚 AD 服务器的问题之前,它更像是一个临时解决方案,但这应该可以做到。
回答by ps2goat
I'm using VSO/Azure DevOps.
我正在使用 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.
The user does not have a license for the extension ms.feed.
回答by Shwe
In my case, I just restarted the docker and just worked.
就我而言,我只是重新启动了 docker 并开始工作。

