I'm using a Ubuntu Server on a VirtualBox machine. Apache and SSH are working, but FTP after successfully connect to the server and login, it sends a error message:

 - Command: PORT 127,0,0,1,180,221 
 - Response: 500 Illegal PORT command.
 - Error: Failed to retrieve directory listing

Port Forwarding:
TCP | Host Port 2100 | Guest Port 21

My vstpd.conf file:

  • Check your logs to see if they give a reason. Also check and see what it says the IP address of the client is when you connect. If it is your real IP address instead of, then that's the problem. – psusi Jan 14 '14 at 19:18
  • @guntbert It's already fixed, this question it's from months ago. – Kenny Jan 17 '14 at 6:55

jackbenny is close...

I am running on AWS with Ubuntu here is what I did to make vsftpd behave correctly:

pasv_address=<(public ip) or (AWS public domain or DNS)>

Then you have to make sure you are allowing ports, 20,21,30000-30100 through. Keep in mind that the port choices 30000-30100 are completely arbitrary and can be whatever you want. Although, I would stick to ports above 10000 and a range of 100 or more.

  • Again, he's not using pssive mode. – psusi Jan 14 '14 at 19:17
  • I know that... however, certain programs will ONLY use passive mode for some commands. For example, the program I was using, I had passive explicitly set to off yet I received this error. So, I did the above and it worked. – Brandon Bearden Jan 16 '14 at 14:48
  • If it had been using passive mode, then it wouldn't get a failure from the PORT command. Passive means use the PASV command instead of PORT. – psusi Jan 16 '14 at 15:39
  • This error manifests when the FTP server changes from listening on port 21 to another, higher port. When a command is issued that uses passive mode, the server establishes a new back connection to the client. This connection extends from the server (outside the firewall boundaries) to a dynamically allocated port number on the client computer. Because the port number is not known in advance, it chooses a random port above 1023 unless specifically given a range to choose within. This port error can most definitely be caused by a command using passive when the server is not setup for passive. – Brandon Bearden Jan 16 '14 at 15:49
  • Thx, it also work for aliyun. – suiwenfeng Jul 8 '17 at 4:52

Did you get that error while connecting from "the outside"? In that case you might need to add your external IP to vsftpd so that it know which IP to send to it's clients when using passive mode FTP.

Try adding pasv_address=<YOUR_IP_HERE> to your config.

You can also try to switch your FTP-client to active mode and see if you still get the same error.

You might also need to set the port range for passiv FTP and also enabling passiv mode FTP. Try addning these lines (replace START_PORT and END_PORT with your desired ports, and also don't forget to port forward them in your router):

  • Locally. I'm still searching information about vftpd behind NAT with no luck. And yes, I switched a few times the mode, but same error appears. – Kenny Oct 13 '13 at 17:49
  • 1
    I think something it's wrong here, passive mode it's from port 2005 to 2010. But FileZilla connects to port 842 (192*4+74). I restarted the service a few times. – Kenny Oct 13 '13 at 17:55
  • That's for when the PASV response has the wrong address... – psusi Jan 14 '14 at 19:16

I don't know what is happening here, but this problem is too damn old. I've finally solved this a few weeks ago when I re installed my virtual machine and followed all the instructions carefully. Answers were so helpful anyways.

  • 2
    If comments are helpful, anywhere on the stackexchange network, please give credit where credit is due (up vote). – Brandon Bearden Jan 16 '14 at 14:49
  • Sorry @BrandonBearden, I forgot to upvote, thanks for letting me now. – Kenny Jan 16 '14 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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