title: Getting FTP working on an Azure VM, overcoming 'connection closed' on ftp client
body: <p>I'm struggling to connect to FTP on a new VM in Azure.</p>
  
  <p>I made a new Virtual Machine from the default image (Windows Server 2012 Datacenter) and RDPed into the new VM. I then enabled the Web Server (IIS) role including the FTP Server and configured IIS using the recommended setting from the Web Platform Installer. I then used the IIS Manager "Add FTP Site..." wizard to add an FTP site with root <code>%systemdrive%\inetpub\ftproot</code> and set the ftp site to have Anonymous Authentication enabled, Allow Anonymous Users Read access, give a Data Channel Port Range 7000-7014, and specify the External IP Address of Firewall as the Public virtual IP (VIP) address from the VM's dashboard in the Azure management portal. </p>
  
  <p>The firewall is also configured to allow the FTP Server.</p>
  
  <p>At this point the FTP service is working. I know because if I open a command prompt on the VM in an RDP session I get the following</p>
  
  <pre><code>C:\Users\slife&gt;ftp 127.0.0.1
  Connected to 127.0.0.1.
  220 Microsoft FTP Service
  User (127.0.0.1:(none)): ftp
  331 Anonymous access allowed, send identity (e-mail name) as password.
  Password:
  230 User logged in.
  ftp&gt;
  </code></pre>
  
  <p>However I cannot connect from elsewhere.</p>
  
  <pre><code>C:\Users\timregan&gt;ftp 111.111.111.33
  Connected to 111.111.111.33.
  Connection closed by remote host.
  </code></pre>
  
  <p>That's from the command prompt in FileZilla I get</p>
  
  <pre><code>Status: Connecting to 111.111.111.33:21...
  Status: Connection established, waiting for welcome message...
  Error:  Could not connect to server
  </code></pre>
  
  <p>I have followed door Ronald's <a href="http://www.itq.nl/blogs/post/Walkthrough-Hosting-FTP-on-IIS-75-in-Windows-Azure-VM.aspx" rel="nofollow noreferrer">Walkthrough: Hosting FTP on IIS 7.5 in a Windows Azure VM</a> and have added two endpoints to allow access to ports 21 (FTP command port) and 20 (FTP data port) and I have used his Azure Powershell suggestion to add the passive port endpoints, e.g.</p>
  
  <pre><code>Get-AzureVM -ServiceName 'blah' -Name 'blah' | Add-AzureEndpoint -Name 'FTPPassive00' -Protocol 'TCP' -LocalPort 7000 -PublicPort 7000 | Update-AzureVM
  </code></pre>
  
  <p>that I can then see in the list of endpoints on the Azure management for the VM.</p>
  
  <p>Why are my connections are not getting through to the FTP server in IIS from outside? How might I diagnose the failure?</p>
  
  <p>========== EDIT 1 ==========</p>
  
  <p>I wondered if <a href="https://stackoverflow.com/a/17263963/575530">the solution that worked for haxor</a> might solve things. That references the answer to '<a href="http://social.msdn.microsoft.com/Forums/windowsazure/en-US/8f697f17-72b7-46f7-8c97-398b91190a2f/server-2012-vm-on-azure-passive-ftp-wont-work" rel="nofollow noreferrer">Server 2012 VM on Azure - Passive FTP Won't Work</a>' on the Windows Azure Virtual Machines forum which notes that if a probe is configures by the Azure Portal on the passive endpoints then they may not work. Although the answer notes that this is fixed in the latest version of the portal it suggests using the Azure Powershell cmdlet Add-AzureEndpoint to ensure no probe is started. I've checked with the Azure Powershell cmdlet Get-AzureEndpoint and none of my ftp endpoints have probes, so that is not my issue here.</p>
  
  <p>========== EDIT 2 ==========</p>
  
  <p>I noticed a step in <a href="http://fabriccontroller.net/blog/posts/passive-ftp-and-dynamic-ports-in-iis8-and-windows-azure-virtual-machines/" rel="nofollow noreferrer">Passive FTP and dynamic ports in IIS8 and Windows Azure Virtual Machines</a> not mentioned in <a href="http://www.itq.nl/blogs/post/Walkthrough-Hosting-FTP-on-IIS-75-in-Windows-Azure-VM.aspx" rel="nofollow noreferrer">the original walkthrough</a>: open the data channel port range (7000-7014) in Windows Firewall. I have added an inbound rule to do that. I still cannot connect.</p>