FTP: ls timeout, even in passive mode

amazon ec2ftptimeout

I'm having trouble listing files on ftp. I can connect properly, but ls doesn't seem to be working.
Output after enabling debug mode is below —

ftp> ls
ftp: setsockopt (ignored): Permission denied
---> PORT xx,xx,xx,xx,xx,xx
200 PORT command successful
---> LIST
425 Unable to build data connection: Connection timed out
ftp> passive
Passive mode on.
ftp> ls
ftp: setsockopt (ignored): Permission denied
---> PASV
227 Entering Passive Mode (xx,xx,xx,xx,xx,xx).
---> LIST


^C
421 Service not available, remote server has closed connection

receive aborted
waiting for remote to finish abort
ftp>

This is happening only on my server (i.e, working perfectly from my local maching). So I'm guessing this has something to do with at the client end — but I have no idea what.

Thanks in advance. Do comment if I should add more info.

Best Answer

ftp really breaks when used behind NATs.

passive ftp will open a random port above 1024 to send the data. active ftp will use port 20 for data and port 21 for commands.

I would use active mode and make sure port 20 and 21 are open and forwarded correctly.