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

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

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


当前回答

在我的情况下,发生这种情况是因为我没有互联网连接,它正在试图搭建

其他回答

我在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.

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

当我试图浏览NuGet包时,我得到了同样的错误,以解决以下相同的步骤:

1-转到%appdata%\NuGet\NuGet.config

2-验证该配置中提到的url

3-删除不需要的url

4-重新启动visual studio并检查

你需要在Nuget中添加代理设置。配置文件。有关详细信息,请参阅此链接:Nuget配置部分和Nuget代理设置。

在我的例子中,问题在于我是在旧的Win7虚拟机上构建的。

我从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 under HKLM\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

(*)更新指的是Microsoft kb3140245: Windows 7更新(KB3140245)

我安装了更新,重新启动(按照更新的要求),添加了那些注册表项,然后Nuget就可以正常工作了。

就我而言,我在不知情的情况下注销了我的工作账户。重新登录我的visual studio帐户解决了这个问题。