Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why do I get kicked out of a FTP session once I run a command? It seems that once I successfully login into a server is get the following after running a command such as "ls" (I've enclosed the error portion in the "[ERROR]" tags):

allen92@allen92-VirtualBox:~/Videos$ ftp -n ftp.FreeBSD.org
Connected to ftp.FreeBSD.org.
220 beastie.tdk.net FTP server (Version 6.00LS) ready.
ftp> user
(username) anonymous
331 Guest login ok, send your email address as password.
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
421 Service not available, remote server has closed connection

This seems to happen on any remote FTP server. Everything works fine when I login onto the local machine and run FTP commands. If in fact the "421" error is a generic error, is there any way to find out the source of the problem? Any leads on this would be appreciated. I haven't been able to find any support on this particular issue. Anybody with an similar problem please share your thoughts.

NOTE: I have VSFTPD installed.

share|improve this question
up vote 6 down vote accepted

There is most likely a NAT-firewall between you and the servers showing the symptom. (NAT-firewalls hide a whole network behind a single IP-number).

The problem is that ftp wants to send the data resulting from the command in a new, separate TCP/IP connection and that cannot go through the firewall because it needs to go from the server to you, and you are hidden behind the firewall. Use the "pasv" command (may be called something different in your client) to change to a passive connection where data connections to go from you to the server.

See http://slacksite.com/other/ftp.html for a more detailed explanation.

share|improve this answer
Thanks, a lot. In the case of VSFTPD, the command for entering passive mode is "passive". That seems to be working for now. I think this whole situation has to do with me running the Linux install on a virtual machine and its not-so-standard settings. I am going to find out how enable "passive" mode by default. Once I find out I'll post for anybody interested. – AllenD Sep 14 '13 at 7:12

Add or enable this line in /etc/vsftpd.conf


share|improve this answer

Your Answer


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.