在尝试连接到Nuget时,我得到了下面的错误,然后我无法连接:

无法加载源的服务索引 https://api.nuget.org/v3/index.json。 发送请求时发生错误。 无法连接到远程服务器 连接尝试失败,原因是被连接方在一段时间后没有正确响应,或已建立连接 由于连接的主机未能响应68.232.34.200:443而失败

我可以在浏览器上访问https://api.nuget.org/v3/index.json。


当前回答

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

其他回答

那些说要删除Nuget的答案。如果您正在使用自定义提要,Config将不起作用。如果您正在使用自定义提要,则需要编辑Nuget。配置文件指向自定义提要的索引。

如果使用Visual Studio 2019,如果你在devenv.exe.config中没有使用任何默认代理,只需删除“defaultproxy”部分。在VS 2017中,这个部分没有出现

改变

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

否则,提供适当的代理用户名和密码。

我通过安装IISCrypto并在命令行上运行来修复这个问题:

IISCryptoCli.exe /template default /reboot

在我的情况下,我失去了与Git的连接。我只是再次添加连接,它工作!:

当我试图在本地托管的Gitlab实例中设置NuGet包时遇到了这个错误。错误提示401未经授权的代码。解决方案是用以下方法去除有害源:

nuget source Remove -Name SOURCE_NAME

然后添加相同的源,但这次在命令中指定用户名和密码:

nuget source Add -Name SOURCE_NAME -Source SOURCE_URL -UserName GITLAB_DEPLOY_TOKEN_USERNAME -Password GITLAB_DEPLOY_TOKEN