How to resolve Nuget Push failures after 5 minutes, even though “-Timeout” value is set as greater than 5 minutes (300 seconds)


If you see Nuget push failing with the following error, it could be due to a known issue by Nuget.

./nuget push largefiletest.1.0.1.nupkg -Source Artifactory3 -Timeout 2400 -Verbosity detailed

Pushing largefiletest 1.0.1 to ''...


System.Net.WebException: The request was aborted: The request was canceled. ---> System.IO.IOException: Cannot close str

eam until all bytes are written.

   at System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean aborting)

   --- End of inner exception stack trace ---

   at System.Net.ConnectStream.CloseInternal(Boolean internalCall, Boolean aborting)

   at System.Net.ConnectStream.System.Net.ICloseEx.CloseEx(CloseExState closeState)

   at System.Net.ConnectStream.Dispose(Boolean disposing)

   at System.IO.Stream.Close()

   at System.IO.Stream.Dispose()

   at NuGet.MultipartWebRequest.CreateMultipartRequest(WebRequest request)

   at NuGet.PackageServer.<>c__DisplayClass4.<PushPackageToServer>b__2(Object sender, WebRequestEventArgs e)

   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)

   at NuGet.HttpClient.RaiseSendingRequest(WebRequest webRequest)

   at NuGet.RequestHelper.GetResponse()

   at NuGet.HttpClient.GetResponse()

   at NuGet.PackageServer.EnsureSuccessfulResponse(HttpClient client, Nullable`1 expectedStatusCode)

   at NuGet.PackageServer.PushPackageToServer(String apiKey, Func`1 packageStreamFactory, Int64 packageSize, Int32 timeo

ut, Boolean disableBuffering)

   at NuGet.PackageServer.PushPackage(String apiKey, IPackage package, Int64 packageSize, Int32 timeout, Boolean disable


   at NuGet.Commands.PushCommand.PushPackageCore(String source, String apiKey, PackageServer packageServer, String packa

geToPush, TimeSpan timeout)

   at NuGet.Commands.PushCommand.PushPackage(String packagePath, String source, String apiKey, TimeSpan timeout)

   at NuGet.Commands.PushCommand.ExecuteCommand()

   at NuGet.Commands.Command.Execute()

   at NuGet.Program.Main(String[] args) 

The error is received because the nuget client is ignoring the "Timeout" value put in, and we found that this is reported to Nuget team .


As a work-around, please set the nuget timeout value that is NOT DIVISIBLE BY 60. For example,  ./nuget push largefiletest.1.0.1.nupkg -Source Artifactory2 -Timeout 2401 -Verbosity detailed