MS Web Deploy fails to deploy with error: error : The underlying connection was closed: An unexpected error occurred on a send.

Shweta Kanade 1 Reputation point
2022-01-03T10:55:22.453+00:00

I am trying to deploy using MS Web deploy but it fails with the error: error : The underlying connection was closed: An unexpected error occurred on a send.
The event logs show below error details,

Message Could not complete the request to remote agent URL 'https://x.x.x.x:8172/msdeploy.axd?site=abc-xyz.com'.

StackTrace An existing connection was forcibly closed by the remote host at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) at System.Net.TlsStream.CallProcessAuthentication(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result) at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size) at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size) at System.Net.ConnectStream.WriteHeaders(Boolean async) --- End of inner exception stack trace --- The underlying connection was closed: An unexpected error occurred on a send. at System.Net.HttpWebRequest.GetResponse() at Microsoft.Web.Deployment.AgentClientProvider.GetHttpResponseHelper(HttpWebRequest request) --- End of inner exception stack trace --- Could not complete the request to remote agent URL 'https://x.x.x.x:8172/msdeploy.axd?site=abc-xyz.com'. at Microsoft.Web.Deployment.AgentClientProvider.GetHttpResponseHelper(HttpWebRequest request) at Microsoft.Web.Deployment.AgentClientProvider.GetHttpResponse(HttpWebRequest request) at Microsoft.Web.Deployment.AgentClientProvider.PerformHeadRequestHelper(Boolean getVersionInfo, Version& maximumSupportedVersion, Version& minimumSupportedVersion) at Microsoft.Web.Deployment.AgentClientProvider..ctor(DeploymentProviderContext providerContext, DeploymentBaseContext baseContext, String serverVersion) at Microsoft.Web.Deployment.DeploymentManager.CreateObjectPrivate(DeploymentProviderContext providerContext, DeploymentBaseOptions baseOptions, DeploymentObject sourceObject, String serverVersion) at Microsoft.Web.Deployment.DeploymentManager.CreateDestinationObject(DeploymentProviderOptions providerOptions, DeploymentBaseOptions baseOptions, DeploymentObject sourceObject, String serverVersion) at Microsoft.Web.Deployment.DeploymentObject.SyncTo(DeploymentProviderOptions providerOptions, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)

Can anyone please help me resolve this error?

Windows development | Internet Information Services
Developer technologies | ASP.NET | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce Zhang-MSFT 3,771 Reputation points
    2022-01-04T02:18:35.08+00:00

    Hi @Shweta Kanade ,

    Firewall is an important thing you need to check, make sure that port 8172 is not blocked and request can get in.

    Then check IIS Management Service has installed on IIS. Configure management service to allow by IP something, note: there is required AT LEAST ONE entry)
    162092-1.jpg

    The last thing is check the TLS on server. Forcing Web Deploy to TLS 1.2 and disabling TLS 1.0.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Bruce Zhang


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.