FTP offers an easy way to transfer files.
However, it can sometimes create annoying errors too.
One such FTP error in cPanel is “failed to retrieve directory listing“.
At 1onlyhost, we help website owners resolve these errors as part of our Dedicated Support Services.
Today, let’s see the top 4 reasons for this error and how we fix them.
Failed to retrieve directory listing in cPanel – What this means?
Website owners commonly see this error when they try to connect to the website using FTP clients such as Filezilla, Cyberduck, etc.
And, customers see the complete error message like this:
Response: 227 Entering Passive Mode (xx,xx,xxx,xxx)
Command: MLSD
Error: Connection timed out
Error: Failed to retrieve directory listing
This error means that the FTP connection was successful. However, the connection can’t get directory listing and hence it gets timeout.
Failed to retrieve directory listing in cPanel – How we fix?
The are many reasons for the error “Failed to retrieve directory listing” in cPanel. The problem may on the server side or on the client side.
Now, let’s discuss the major reasons for this error and how our Dedicated Engineers rule out each possibility.
1) Port range not open on server
The proper functioning of FTP requires the server to accept connection on standard FTP ports such as 20, 21, etc. In addition to that, server should accept connections on passive port ranges. And, most of the FTP clients use passive mode as the default mode. The passive port ranges varies from server to server.
Also, these ports are not enabled by default. If it’s not specifically set to allow connections to these passive ports, the FTP connection will fail. We’ve seen instances where passive ports get blocked in newly setup VPS servers, FTP servers, etc.
How we fix?
Firstly, our Support Engineers ensure that connection to the standard FTP ports works fine using the telnet command.
telnet xx.xx.xx.xx 20
telnet xx.xx.xx.xx 21
Secondly, we verify that passive port range is properly added in the FTP server configuration file. On cPanel servers with PureFTPd server, we enable the required passive port range by adding the following line to the configuration file /var/cpanel/conf/pureftpd/local.
PassivePortRange: xxxxx xxxxx
Similarly, on a ProFTPd server, we add the below lines in the configuration file /var/cpanel/conf/proftpd/local.
PassivePorts: xxxxx xxxxx
Further, we configure the server firewall and open these passive port range. For example, in iptables, we open the passive port range using the below command.
iptables -I INPUT -p tcp --dport xxxxx:xxxxx -j ACCEPT
On cPanel servers with CSF firewall, we allow the passive ports in TCP_IN settings of CSF configuration file /etc/csf/csf.conf.
TCP_IN = "xxxxx:xxxxx";
Most importantly, we restart the FTP service to bring these changes into effect.
In some cases, our Support Experts ensure that the ForcePassiveIP parameter in the configuration is set to the FTP server’s public IP address to allow connections.
Once we confirm there are no issues on the server side, we check the possibilities at the client side.
[Need to enable Passive ports on your server? Our Support Experts can help you here.]
2) Firewall or Antivirus restrictions
Another probable reason is that the FTP connection is blocked by the customer’s local firewall or antivirus programs. In other words third party firewall or Antivirus on the user’s system blocks the FTP connection. In addition to that, firewall at the ISP end or router end can also create problems.
How we fix?
Our Support Experts first verify the FTP connectivity from the client’s system using the telnet command.
telnet xx.xx.xx.xx 21
telnet xx.xx.xx.xx 20
In addition to that, we ask the customers to temporarily disable security applications such as firewall(Windows firewall, third party firewall), Antivirus software, etc. one by one. This helps us to identify the application that is creating problems and fix it’s settings.
Similarly, we get the traceroute results from the customer as well. Also, we ask users to turn off their intermediate devices such as routers, gateways, etc. to establish a direct connection. In this way, we identify if the issue lies at the intermediate level.
3) Unsupported FTP features
Some hosts provide FTP connection over SSH(SFTP) which uses port 22. Similarly, some host offers FTP connection over SSL/TLS.
We’ve seen instances where customers try to establish a secure FTP connection via SSH or SSL, but their web hosting provider doesn’t provide this facility. In such cases, the server firewall blocks the connection and users see the error failed to retrieve directory listing in cPanel.
How we fix?
Here, our Support Experts get the FTP client settings used by the customer and verify the encryption method used by the customer. If customer uses an unsupported encryption type, we ask them to use the basic FTP protocol.
For example, in Filezilla, we change the encryption type from File > Site Manager > General > Encryption > Only use plain FTP. Also, change the logon type as Normal.
4) FTP client set to Active mode
FTP transfer can occur in Active and Passive modes.
We’ve seen instances where users configure the FTP clients to transfer the files in Active mode. In such cases, the FTP client needs to know the external IP address to connect. So, users need to specify where to get this external IP address. Any wrong setting here can create problems.
For example, one common mistake that we see is that users set the external IP to get from the default filezilla URL http://ip.filezilla-project.org/ip.php. This will return the localhost(127.0.0.1) IP address and thus result in error.
How we fix?
We always suggest that customers use Passive mode for FTP transfer. If customers specifically need Active mode for FTP transfer, then we’ll help users navigate the settings and enable Active mode.
For example, on Filezilla, our Support Engineers switch between Active and Passive mode from File > Site Manager > Transfer Settings > Transfer mode.
However, while activating Active mode in Filezilla, we ensure the following settings are enabled as well.
Click on Connection -> FTP -> Active Mode: Select “Ask your operating system for the external IP address”
Click on Connection -> FTP -> Passive Mode: Choose Fall Back to Active Mode
[Need an expert to resolve this FTP error on your cPanel/WHM server? We are here for your help.]
Conclusion
In short, FTP error “failed to retrieve directory listing” in cPanel occurs due to server firewall restrictions, ftp client settings and more. Today, we’ve discussed the top 4 reasons for this error and how our Dedicated Engineers fix them.