I'm at a bit of a loss here, having checked all the usual suspects.

One of the most baffling things is that I can deploy via Visual Studio on the Build Agent server, using the same url to the same server, same code (Literally copied the Visual Studio solution from the build agent s folder of the latest build)

When building via TFS 2015 however, I'm seeing the following:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(4276,5): Error : Web deployment task failed. (Could not complete the request to remote agent URL 'https://siteurl:8172/msdeploy.axd?site=sitename'.)

This error indicates that you cannot connect to the server. Make sure the service URL is correct, firewall and network settings on this computer and on the server computer are configured properly, and the appropriate services have been started on the server.

Error details:

Could not complete the request to remote agent URL 'https://siteurl:8172/msdeploy.axd?site=sitename'.

The underlying connection was closed: An unexpected error occurred on a send.

Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

An existing connection was forcibly closed by the remote host

In addition, the WMsvc log on the target IIS server does not show a request hitting the server when TFS does the build, however when Visual Studio does the build, it does reach the server.

The MSBuild arguments passed in TFS (line breaks added for readability):

username=$(Web Deploy Username);
password=$(Web Deploy Password);

The build definition was copied from another working build with the only changes being the url and the configuration.

It seems like it's a network issue, but I don't know why it would work from the same server via Visual Studio, but not via TFS if the source (TFS Build Agent server) and the destination (IIS Web server) are the same, the port is the same, both using https, Web Deploy etc.

Any ideas on how to further debug?

Additional Info:

Target Server: Windows Server 2012R2 (VM on Azure)

1 Answer 1


Check for TLS mismatch. We were using SchUseStrongCrypto reg key to force TLS 1.2 on one machine and not the other. This resulted in the "forcibly closed" same as the OP experienced. Blogged more detail here https://fuseit.zendesk.com/hc/en-us/articles/360000328595

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.