Error pushing Nuget Package - Unhandled exception from web server: Incorrect function


We’re having problems trying to push a Nuget package to Octopus via VSTS.

The error message in VSTS is:
Pushing ACME 1.1.19 to ‘/octopus/nuget/packages’…
The request was aborted: The request was canceled.
Failed to push packages. Make sure the feed URL is correct, and the packages have unique version numbers.
Unexpected exit code 1 returned from tool NuGet.exe

After investigating this error, we reviewed the Octopus Diagnostics Server Logs. There, we are seeing the following error:

Unhandled exception from web server: Incorrect function
System.Net.HttpListenerException (0x80004005): Incorrect function
at System.Net.HttpRequestStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.Stream.InternalCopyTo(Stream destination, Int32 bufferSize)
at Nancy.IO.RequestStream.MoveStreamContentsToFileStream()
at Nancy.IO.RequestStream.MoveStreamOutOfMemoryIfExpectedLengthExceedSwitchLength(Int64 expectedLength)
at Nancy.IO.RequestStream…ctor(Stream stream, Int64 expectedLength, Int64 thresholdLength, Boolean disableStreamSwitching)
at Octopus.Server.Web.OctopusNancyHost.ConvertRequestToNancyRequest(HttpListenerRequest request) in y:\work\refs\heads\release\source\Octopus.Server\Web\OctopusNancyHost.cs:line 291
at Octopus.Server.Web.OctopusNancyHost.Process(HttpListenerContext ctx) in y:\work\refs\heads\release\source\Octopus.Server\Web\OctopusNancyHost.cs:line 426

We are using Octopus version

We were hoping that someone may be able to provide assistance with this issue.


Hi Ryan,

I think it is possible that Octopus Server error is unrelated.

Your VSTS error message indicates you are attempting to push the package to the URL: /octopus/nuget/packages. I believe that should be an absolute URL, e.g.

Does it resolve the problem if you use an absolute URL?


Hi Michael,

Thank you for taking the time to reply.

Unfortunately, I don’t think this is the issue. I actually omitted the full URL for security reasons. The URL appears something like:

Pushing ACME 1.1.19 to ‘http://AMCE01/octopus/nuget/packages’…

Any other thoughts?


Hi all. Just something else I found. It looks like this error has been discussed previously. However, it’s a private support message.


In that private thread, the problem was a timeout.

We might need a little more information in this case. What is the step you are running in VSTS? And what parameters are supplied to it? Can you possibly get a verbose build log? What we’re looking for are the arguments used to invoke nuget.exe (as listed in the Push section here).