Skip to content
August 25, 2015 / kiranpatils

One-Click Publish in Visual Studio showing an error The underlying connection was closed: An unexpected error occurred on a send


If you are using Visual Studio one click publish, and you are facing following error (We were getting it while doing publish from Build server to Target server.)

Web deployment task failed. (Could not complete the request to remote agent URL ‘https://<HOSTNAME/IP&gt;:8172/msdeploy.axd?site=<OURWEBSITE>’.)
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://<HOSTNAME/IP&gt;:8172/msdeploy.axd?site=<OURWEBSITE>’.
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                   0              0              WEBSITENAME

Or any other error related to Web Deploy [a.k.a. MsDeploy] technology used behind the scenes of Visual studio publish. Then this post is for you!


This is the error, Which took days and days for us. Because all settings were working since couple of years and suddenly it stopped working. Without getting any clue. This is what we did for troubleshooting:

  1. Disable Firewall/Antivirus, Allow Port 8172
  2. Make sure Hostname/IP gets resolved
  3. Server’s IP and Port number is reachable : Yes – We verified it using Telnet and it can connect to Port 8172  and also verified Firewall rules as well – All good!
  4. Verified all Web deploy related services are fine or not – and they are fine – We tried to run Powershell script given by Microsoft in Reference Link #2 – But no luck
  5. Verified username and password are fine – They are fine – Verified it using remote desktop with those credentials
  6. Reinstalled MSDeploy on SBX – and It didn’t helped
  7. No any log entry in MS Deploy IIS Log [HEAD/POST]
  8. Tried with MSDeploy command : msdeploy.exe -verb:dump -source:iisapp=”Default Web Site”,computername=https://:8172/msdeploy.axd?site=Default%20Web%20Site,username=,password=,authType=basic  -verbose –whatif
  9. Fired MS deploy command from my local – as given in earlier email and monitored packets on SBX server using TCPView and netstat command : Found that : TCP Packet gets sent on 8172 and status : SYNC_RCVD – and then it drops packet

During this whole process. This is what we understood:

– Web Management Service listens on 8172
– If request received it calls MsDeploy.axd

Somehow, packet gets reached to Machine – But after that it should forward it to IIS – And in turn IIS will send it to MsDeploy – And looking at log files – Packet is being dropped at machine level


We raised ticket with Microsoft Support folks and this has been fixed by changing Server URL to : http://<HOSTNAME/IP&gt;  from : https://<HOSTNAME/IP&gt;:8172/msdeploy.axd [Reference link :]

To be honest — We haven’t been able to find out why earlier URL was working earlier and not working now!



Leave a Comment
  1. sshah2891 / Aug 25 2015 6:12 pm

    Wow nice workout sir will be helpful to us


    Shivam Shah
    IT professional & Web Developer
    Bachelor of Computer Application
    Ph. 519-331-5260


  2. Jeremy Cook / Jun 1 2016 10:32 pm

    One thing I ran into is WebDeploy (as of v3.6) stops working if TLS 1.0 is disabled. So if you’ve disabled TLS 1.0 and earlier for PCI compliance or as a best practice then you will hit this. By using http:// you are not using SSL/TLS which would bypass any TLS issues, and I believe that you end up using the older MSDEPLOYAGENTSERVICE service instead of msdeploy.axd as well.

    • kiranpatils / Jun 2 2016 12:10 pm

      Sounds good. Thanks for sharing!

  3. Dimitris van Leusden / Aug 22 2017 7:17 am

    I’d like to share something that tortured me for some hours: In case you have disabled some ciphers using tools such as IIS Crypto, there will be problems with SSL negotiation from within VS.

    This will result in getting the message:

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

    Create this .reg file as mentioned on the link below, run it, close VS and reopen.


  1. Configuring Web Deploy on your Sitecore server | Sitecore basics!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: