Fix cPanel FTP Failed to retrieve Directory Listing Error

Failed to retrieve Directory Listing error is most probably occurred due to the passive ports are not opened on the cPanel server. That is, we need to open that port in the server to work the FTP. In the case of passive mode FTP, the client will initiate a connection to the server. This process is most effective because most firewalls allow inbound traffic from sessions initiated by the client.

 

Enable passive port range on Pure-FTPd

To enable passive post in Pure-FTPd you need to follow below steps.

1) Login to the server as root user.

2) Open  /etc/pure-ftpd.conf file and remove the # symbol before  PassivePortRange option.

3) Add the PassivePortRange option to a port range that is greater than or equal to 1024.

#  /etc/pure-ftpd.conf

PassivePortRange 49152 65534

4) If the FTP server is behind a network address translation server you need to add the below lines in the configuration file.

# /etc/pure-ftpd.conf

ForcePassiveIP your FTP server’s public IP address

5) Save the changes that you made.

6) Open the ports using the below command.

# iptables -I INPUT 2 -p tcp –dport 49152:65534 -j ACCEPT

# service iptables save

7) Restart FTP service using the below command

#  /scripts/restartsrv_ftpserver

8) To make the change permanent you need to add the port numbers in pureftpd configuration file.

echo “PassivePortRange: 49152 65534” >> /var/cpanel/conf/pureftpd/main

/usr/local/cpanel/scripts/setupftpserver pure-ftpd –force

 

Enable the passive port range for ProFTPd

1) To add the passive ports, just add the below line in the  /etc/proftpd.conf configuration file.

PassivePorts 49152 65534

2) If the FTP server is behind a network address translation server you need to add the below lines in the configuration file.

MasqueradeAddress domainname.com

MasqueradeAddress your FTP server’s public IP address

3) Save the changes that you made.

4) Add the ports in the server firewall using the below commands.

# iptables -I INPUT 2 -p tcp –dport 49152:65534 -j ACCEPT

# service iptables save

5) Restart the FTP server to enable the changes.

# /scripts/restartsrv_ftpserver

6) To enable the changes permanently you need to add the port in the configuration file

echo “PassivePorts: 49152 65534” >> /var/cpanel/conf/proftpd/main

/usr/local/cpanel/scripts/setupftpserver proftpd –force

Now you can able to connect the FTP client without any issue.

Leave a Reply