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

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

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


当前回答

我有一对Windows 2016服务器,其中Visual Studio无法连接到NuGet。在尝试了几乎所有其他建议的修复(注册表更改,Visual Studio/NuGet相关的缓存清理或文件/配置更改)后,以下是我们解决它的方法。

我们有一个组策略(GPO),设置了密码,我将这些密码添加到我们的GPO密码列表中,以使其工作。

TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256

https://github.com/NuGet/Announcements/issues/60

其他回答

该错误可能是由临时网络问题引起的,如果重试,该错误将消失。

在我的情况下,我有Fiddler运行,改变了我的代理设置

删除% AppData % \ \ NuGet \ NuGet徘徊。配置和重新启动VS2019对我来说很有效。

类似于https://github.com/NuGet/Home/issues/3281

我在Visual Studio 2015上执行Install-Package Modernizr时遇到了类似的问题。我通过以下步骤解决了这个问题:

Download the package from its online source. Go to Tools/NuGet Package Manager/Package Manager Settings. Select Package Sources from the window. Add a new package source by clicking on the + sign. Enter a name and source location by clicking on ... (triple dot) sign. Make sure that only the package source that you've just added is checked. Uncheck all the other package sources. Go to Package Manager Console and type Install-Package Modernizr. Visual Studio 2015 installs the package automatically and creates Scripts and packages folders in your root folder.

我希望同样的解决方案在安装其他包时也能起作用。

我有一个类似的问题,试图连接到我的私人TFS服务器,而不是公共NuGet API服务器。由于某种原因,我在AD服务器和TFS服务器之间出现了问题,因此它总是返回401。NuGet配置文章展示了你可以像这样将你的AD用户名和密码添加到配置文件中:

  <packageSourceCredentials>
      <vstsfeed>
          <add key="Username" value="yourname@company.com" />
          <add key="Password" value="this is an encrypted password" >
          <!-- add key="ClearTextPassword" value="not recommended password" -->
      </vstsfeed>
  </packageSourceCredentials>

这不是一个非常理想的解决方案,更像是一个临时的解决方案,直到我可以找出AD服务器的问题,但这应该可以解决问题。