Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using Windows 7 and have multiple FTP client applications working without any problem. However when I use command-line FTP, I can get connected, log in (after entering user name and password) but it always get disconnected when dir or ls command is used. The response is "Connection closed by remote host".

Any tip would be greatly appreciated.

share|improve this question
    
Google is your friend. forums.iis.net/p/1167108/1942029.aspx google.com/… –  Fantomas Nov 28 '10 at 3:06
add comment

4 Answers

up vote 7 down vote accepted

You'll usually see this type of thing happen when the server tries to connect back to you but can't. FTP originally used two TCP channels. One was for commands, and the other for transferring data. When you run the dir command it uses a data channel. The data channel is established on demand and results in the server trying to connect back to you.

That's most likely being blocked by your router or windows firewall. What you need is a client that supports PASV mode.

You can enable PASV mode in internet explorer. http://compnetworking.about.com/cs/novellgroupwise/ht/setpassiveftpie.htm

Or use a different client. I'm not sure if the command line version can use PASV mode. It's a very basic client.

share|improve this answer
    
Thanks, Matt. I thought the command-line FTP client used passive mode by default but I have just found multiple posts saying Windows command-line FTP actually excludes passive mode. IE always works fine on my machine for FTP. I just want to use command-line to examine some raw data from an FTP server. –  Hong Nov 28 '10 at 4:53
    
As an experiment, you could see if enabling or disabling PASV in internet explorer makes a difference.. or gives similar or the same error. –  barlop Nov 28 '10 at 23:15
    
ftp> PASV - Invalid command. (Windows 7 Ent.). This answer is exactly what happens at work. –  Bratch Jun 28 '12 at 17:10
2  
it needs to be QUOTE PASV –  JosephStyons Jul 10 '12 at 5:29
add comment

I had an issue with transmitting files via FTP once I was logged into the box in question. It would create the file name, but the file was empty. I resolved by doing the following:

  • go to Control Panel → Windows Firewall → Advanced Settings → Inbound Rules
  • double-click the Name column to sort by name
  • scroll down until you see two rules called "File Transfer Program"; these were set to Block on my PC (big red circle with a line through it)
  • double-click on the rule
  • on the General tab, under Action, set to "Allow the connection"
  • click OK
  • do this for the other rule

Should be good to go now.

share|improve this answer
add comment

I was experiencing the same issue with 3rd party POS software on a Windows 7 machine that batches client transaction data over back to a SQL server.

It worked fine until the client location changed ISPs and, therefore, static IPs. Command line FTP commands did not work beyond the initial login and none of the remedies I found online or this thread worked.

Just for kicks, I re-created the FTP rule in the firewall, a cheapo D-Link, and viola, it seems to be working again.

share|improve this answer
add comment

I encountered this problem on a Windows 2008 server.

This article suggests enabling the Application Layer Gateway Service. This did not fix the problem for me.

What did fix the problem was adding an exception in the Windows Firewall for C:\Windows\system32\ftp.exe

share|improve this answer
    
By default windows firewall include ftp.exe in its exception but only for home/work network. Make sure you are not on public network else allow ftp for public network as well. –  Jags Mar 5 at 15:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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