VSFTP failed to retrieve directory listing

5,613

Your port forwarding is wrong.

You should not forward 10090-10100 to 2121 (which is the FTP servers main listening port). You should forward them to ports 10090-10100 on the FTP server.

FTP opens an extra connection for data transfer, which is what this port range is used for. This of course means that they need to be forwarded to the data ports, not the control port.

Also, consider not using FTP. What you are experiencing is one reason. The lack of security by default is another. It's also a slow protocol, and downloading a single file has a lot of overhead. For authenticated users, sftp, scp and webdav may be good alternatives. For anonymous access, http(s) is a better solution. FTP is not secure, nor is it a good protocol by todays standard.

Share:
5,613

Related videos on Youtube

Hamdi Dousdou
Author by

Hamdi Dousdou

Updated on September 18, 2022

Comments

  • Hamdi Dousdou
    Hamdi Dousdou over 1 year

    I want to set up a FTP server but when I try to connect with filezilla I got this error prob:

    Status: Connecting to 41.228.175.x:2121...
    Status: Connection established, waiting for welcome message...
    Status: Insecure server, it does not support FTP over TLS.
    Status: Server does not support non-ASCII characters.
    Status: Logged in
    Status: Retrieving directory listing...
    Command:    PWD
    Response:   257 "/" is the current directory
    Command:    TYPE I
    Response:   200 Switching to Binary mode.
    Command:    PASV
    Response:   227 Entering Passive Mode (41,228,175,x,39,110).
    Command:    LIST
    Response:   425 Failed to establish connection.
    Error:  Failed to retrieve directory listing
    Status: Connection closed by server
    Status: Disconnected from server
    Status: Connecting to 41.228.175.x:2121...
    Status: Connection established, waiting for welcome message...
    Status: Insecure server, it does not support FTP over TLS.
    Status: Server does not support non-ASCII characters.
    Status: Logged in
    Status: Retrieving directory listing...
    Command:    PWD
    Response:   257 "/" is the current directory
    Command:    TYPE I
    Response:   200 Switching to Binary mode.
    Command:    PASV
    Response:   227 Entering Passive Mode (41,228,175,x,39,107).
    Command:    LIST
    Response:   425 Failed to establish connection.
    Error:  Failed to retrieve directory listing
    Status: Connection closed by server
    

    and this is my vsftpd.conf file configuration:

    listen=YES
    xferlog_enable=YES
    log_ftp_protocol=YES
    seccomp_sandbox=NO
    listen_port=2121
    pasv_enable=YES
    port_enable=YES
    pasv_address=41.228.175.x
    pasv_addr_resolve=YES
    pasv_max_port=10100
    pasv_min_port=10090
    listen_ipv6=NO
    session_support=YES
    file_open_mode=0755
    listen_ipv6=NO
    anonymous_enable=NO
    userlist_enable=YES
    userlist_file=/etc/vsftpd.userlist
    userlist_deny=NO
    tcp_wrappers=YES
    allow_writeable_chroot=YES
    user_sub_token=$USER
    local_root=/home/$USER/ftp
    local_enable=YES
    write_enable=YES
    local_umask=077
    dirmessage_enable=YES
    use_localtime=YES
    xferlog_enable=YES
    connect_from_port_20=NO
    chown_username=admin
    xferlog_std_format=YES
    idle_session_timeout=600
    accept_timeout=60
    connect_timeout=60
    session_support=YES
    data_connection_timeout=300
    ascii_upload_enable=YES
    ascii_download_enable=YES
    ftpd_banner=Welcome to blah FTP service.
    chroot_local_user=YES
    chroot_local_user=YES
    chroot_list_enable=YES
    chroot_list_file=/etc/vsftpd.chroot_list
    userlist_file=/etc/vsftpd.userlist
    secure_chroot_dir=/var/run/vsftpd/empty
    pam_service_name=vsftpd
    rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
    rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
    ssl_enable=NO
    utf8_filesystem=YES
    

    Screenshot of portforwarding settings for the PASV port range: PASV port forwarding

    • vidarlo
      vidarlo over 6 years
      Have you forwarded ports for pasv mode?
    • Hamdi Dousdou
      Hamdi Dousdou over 6 years
      yes i did it like this in screenshot : ufile.io/jx660
    • vidarlo
      vidarlo over 6 years
      Please use a service like imgur that doesn't require people to wait or download files to view your image.
  • Hamdi Dousdou
    Hamdi Dousdou over 6 years
    thanks for your response but in the router interface i can't make a nat for a range port i just cant put one port
  • vidarlo
    vidarlo over 6 years
    Then you need to make it individually, for each and every port in the PASV range. But my guess is that you can - just leave the destination port blank.