在尝试连接到Nuget时,我得到了下面的错误,然后我无法连接:
无法加载源的服务索引 https://api.nuget.org/v3/index.json。 发送请求时发生错误。 无法连接到远程服务器 连接尝试失败,原因是被连接方在一段时间后没有正确响应,或已建立连接 由于连接的主机未能响应68.232.34.200:443而失败
我可以在浏览器上访问https://api.nuget.org/v3/index.json。
在尝试连接到Nuget时,我得到了下面的错误,然后我无法连接:
无法加载源的服务索引 https://api.nuget.org/v3/index.json。 发送请求时发生错误。 无法连接到远程服务器 连接尝试失败,原因是被连接方在一段时间后没有正确响应,或已建立连接 由于连接的主机未能响应68.232.34.200:443而失败
我可以在浏览器上访问https://api.nuget.org/v3/index.json。
当前回答
如果使用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>-->
否则,提供适当的代理用户名和密码。
其他回答
在我的情况下,我必须在Visual studio Options->NugetPAckageManager->sources中添加源 然后重新启动visual studio命令提示符
当我试图浏览NuGet包时,我得到了同样的错误,以解决以下相同的步骤:
1-转到%appdata%\NuGet\NuGet.config
2-验证该配置中提到的url
3-删除不需要的url
4-重新启动visual studio并检查
也许这有帮助
对我来说,删除位于C:\Users\YourNameHere的.nuget文件夹解决了这个问题。
如果您得到此错误,但没有代理服务器,则可以转到
%userprofile%\AppData\Roaming\NuGet\NuGet.Config
并注释这行:
<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>
它为我工作,因为我得到了这个错误,但我没有代理服务器。
我删除了%localappdata%/Nuget中的所有内容,并清除了NuGets缓存。
dotnet nuget locals all --clear
重新启动后,Visual studio 2022恢复了我的包。