Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet.exe from command line gives "existing connection was forcibly closed by the remote host" error

I'm having problems calling NuGet.exe from the command line:

nuget.exe restore solution.sln

On my local machine, this runs without issue from the command line. On the build server, I immediately see the below error:

An existing connection was forcibly closed by the remote host

For background I'm in the process of setting up Jenkins on our build server for our .NET Framework applications.

This error occurs regardless of whether I have Jenkins run the command or I spin up a CMD window (Administrator or otherwise) and run it myself. Even the -Verbosity detailed flag comes up with nothing.

Oddly, when doing a restore against the solution within Visual Studio 2017, it works fine.

Has anyone come across this before or have any ideas?

like image 973
richaswr Avatar asked Sep 12 '25 22:09

richaswr


2 Answers

So this turned out to be a problem with TLS. Having looked up a lot of articles and knowing some ongoing issues with TLS in various places I found this article: Deprecating TLS 1.0 and 1.1 on NuGet.org

I applied the registry changes mentioned there (as below) and suddenly I got beyond this error

reg add HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 /v SystemDefaultTlsVersions /t REG_DWORD /d 1 /f /reg:64
reg add HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 /v SystemDefaultTlsVersions /t REG_DWORD /d 1 /f /reg:32
like image 106
richaswr Avatar answered Sep 15 '25 12:09

richaswr


I have seen similar behavior and it was due to our IT Security team blocking that particular domain. I could access it from our dev machines, but the build server (which was running not attached to the domain) was blocking.

like image 41
Hal Avatar answered Sep 15 '25 11:09

Hal