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

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

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


当前回答

我试图添加一个Azure Artifacts NuGet源。

在这里,我遵循了微软的指示,但有一个关键的疏忽。

我忘记替换/v3/index了。Json和/v2。

其他回答

也许这有帮助

对我来说,删除位于C:\Users\YourNameHere的.nuget文件夹解决了这个问题。

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

我在Windows 10中使用docker-compose up命令在Dockerfile中运行RUN dotnet restore时遇到了同样的错误。

我已经尝试了互联网上提供的所有可能的解决方案,也一直在关注这个公开的问题。最后,在花了8个多小时后,通过遵循前面的步骤,我能够解决我的问题。

Uninstall Docker from your system Restart your system Install Docker from this link. Below is the version of my Docker Restart your system Start Docker for Windows, search Docker in the search bar in Windows. Make sure it is running. You should also go to Services.msc and make sure the services Docker Engine and Docker for Windows Service are running. At last, you must check your Nuget.config file from C:\Users\{Username}\AppData\Roaming\NuGet. For me, the content of that file was as below. <?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> </packageSources> <packageRestore> <add key="enabled" value="True" /> <add key="automatic" value="True" /> </packageRestore> <bindingRedirects> <add key="skip" value="False" /> </bindingRedirects> <packageManagement> <add key="format" value="0" /> <add key="disabled" value="False" /> </packageManagement> </configuration> Hope this helps.

如果您看到如下错误,您可能需要设置Azure Artifacts凭据,请参阅Github链接,您可以通过运行powershell脚本或手动安装凭据提供程序。

error :   Response status code does not indicate success: 401 (Unauthorized).

如果您得到此错误,但没有代理服务器,则可以转到

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

它为我工作,因为我得到了这个错误,但我没有代理服务器。