Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I was practicing ftp but faced an issue: ls command isn't working on ftp> . Why? I checked on 2 remote servers but ls didn't work on either and gave different output when ls was executed. Please see below for the 2 remote boxes.

The below shows my remote server where I installed vsftpd today.

ravbholua@ravbholua-Aspire-5315:~$ ftp rs
Connected to
220 (vsFTPd 3.0.2)
Name (rs:ravbholua): 
331 Please specify the password.
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/home/ravbholua"
ftp> ls
500 Illegal PORT command.
ftp: bind: Address already in use

The below is for a different remote machine where I have to send some files. But as ls on ftp> isn't working, how will I transfer files from my local box to that box because I can't be confirmed without ls whether the files have been transferred or not.

ravbholua@ravbholua-Aspire-5315:~$ ftp
Connected to
220---------- Welcome to Pure-FTPd [TLS] ----------
220-You are user number 1 of 10 allowed.
220-Local time is now 04:34. Server port: 21.
220-This server supports FXP transfers
220 You will be disconnected after 2 minutes of inactivity.
Name ( peacenews
331 User peacenews OK. Password required
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
200-FXP transfer: from to
200 PORT command successful

Please note that for the above machine, once I ran ls on ftp>, the prompt didn't come back.

On both the remote machines, I got different output when executed ls on ftp>

share|improve this question
use passive mode. Check the man page of your ftp client for how to enable it. – Stéphane Chazelas Oct 4 '13 at 12:58
How to know what ftp client is running at my end? – Ravi Oct 5 '13 at 6:37
@stephane thanks! I ran man ftp and found the -p option to be used for passive mode. As man ftp mentions that ftp is a user interfacei to the Internet standard file transfer protocol: so it's interface and not the ftp client!!! What I understand is the ftp client uses this interface (ftp) for transferring files. – Ravi Oct 5 '13 at 7:01

2 Answers 2

up vote 10 down vote accepted

FTP is an ancient protocol. It relies on two TCP connections: a control connection over which commands are exchanged, and data connections for the content of files and also for the output of commands such as ls. What's happening here is that the control connection is established, but the data connections aren't going through.

By default (active mode), data connections are established from the sender to the receiver. For the output of ls, the data is sent by the server, so the server attempts to open a connection to the client. This worked well when FTP was invented, but nowadays, clients are often behind a firewall or NAT which may or may not support active FTP. Switch to passive mode, where the client always initiates the data connection.

Check the manual of your ftp command to see how to switch to passive mode by default. For a one-time thing, typing the command passive usually does the trick.

You may wish to switch to a nicer FTP client such as ncftp or lftp.

share|improve this answer
Thanks!! But why all of a sudden this issue occured. Eariler I was able to run ls on ftp>. But yesterday, I installed vsftpd on my remote server (my VPS) and also edited file .netrc on my local box (simply had put hash at the beginning of the line in .netrc). That's all and then after the issue of ls I have been facing. What may be the reason that ls was working fine earlier and since yesterday not working? – Ravi Oct 5 '13 at 6:35
You are right to suggest lftp. I am having experience working with that. lftp is really amazing. Also I would like to add that I have just now checked with lftp and it is perfectly running fine having no issue of ls. ls here (in lftp)is displaying the output properly. – Ravi Oct 5 '13 at 6:38

Full Complete solution for "ftp 500 Illegal PORT command". Click the following link:


Trying to connect the ftp server & getting 500 Illegal port command. This issue may occur when ftp program is not configured for Passive mode.

You may get error snippet such as:

COMMAND:>              [3/11/2015 1:17:05 PM] PORT 192,168,0,101,196,215    
                       [3/11/2015 1:17:05 PM] 500 Illegal PORT command.    
ERROR:>                [3/11/2015 1:17:05 PM] Syntax error: command unrecognized.    
ERROR:>                [3/11/2015 1:17:05 PM] Failed to establish data socket.

To resolve this issue you can define the port or ftp in configuration file of ftp server & define the IP Address or PASV server.

Check the configuration file for below settings.

pasv_max_port=Enter the max port range allowed on your server.
pasv_min_port=Enter the min port range allowed on your server.
pasv_address=Ip Address of your server.

After that restart the ftp service & check the ftp connection.

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.