Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SOLVED FTP Connects but Timeout with Error Failed to retrieve directory listing

Discussion in 'General Discussion' started by Success1, Sep 8, 2016.

Tags:
  1. Success1

    Success1 Member

    Joined:
    Sep 8, 2016
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Famunda
    cPanel Access Level:
    Root Administrator
    We are in the process of setting up a new server and anytime we try to connect via FTP we get a message stating a successful login, but the connection can not get a directory listing.

    We have tried using the default cPanel user and tried setting up another test FTP account but all ends in the below Error Messsage.

    Code:
    Status:    Disconnected from server
    Status:    Resolving address of *****
    Status:    Connecting to **.**.**.**:21...
    Status:    Connection established, waiting for welcome message...
    Status:    Logged in
    Status:    Retrieving directory listing...
    Command:    PWD
    Response:    257 "/" is your current location
    Command:    TYPE I
    Response:    200 TYPE is now 8-bit binary
    Command:    PASV
    Response:    227 Entering Passive Mode (**,**,**,**,176,105)
    Command:    MLSD
    Error:    The data connection could not be established: ETIMEDOUT - Connection attempt timed out
    Error:    Connection timed out after 40 seconds of inactivity
    Error:    Failed to retrieve directory listing
    Status:    Disconnected from server
    Status:    Resolving address of *****
    Status:    Connecting to **.**.**.**:21...
    Status:    Connection established, waiting for welcome message...
    Status:    Logged in
    Status:    Retrieving directory listing...
    Command:    PWD
    Response:    257 "/" is your current location
    Command:    TYPE I
    Response:    200 TYPE is now 8-bit binary
    Command:    PASV
    Response:    227 Entering Passive Mode (**,**,**,**,118,88)
    Command:    MLSD
    Error:    The data connection could not be established: ETIMEDOUT - Connection attempt timed out
    Error:    Connection timed out after 40 seconds of inactivity
    Error:    Failed to retrieve directory listing
    
     
  2. mtindor

    mtindor Well-Known Member

    Joined:
    Sep 14, 2004
    Messages:
    1,344
    Likes Received:
    58
    Trophy Points:
    178
    Location:
    inside a catfish
    cPanel Access Level:
    Root Administrator
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #2 mtindor, Sep 8, 2016
    Last edited by a moderator: Jul 25, 2018
    kwdamp and cPanelMichael like this.
  3. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,895
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    Yes, as mentioned in the previous post, you should be able to follow the instructions on the following document to address the problem:

    How to Enable FTP Passive Mode - cPanel Knowledge Base - cPanel Documentation

    Starting with version 60, the cPanel installation process will automatically enable passive mode and ensure the required ports are open as part of the standard firewall configuration.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Ally

    Ally Registered

    Joined:
    May 5, 2017
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Canada
    cPanel Access Level:
    Root Administrator
    I am having these exact same problems. I have tried various things such as work with the firewall, and attempt to change to passive mode. When I am in the Cpanel, looking at etc. file I do not see the files I am supposed to be working with and editing (I read the above suggested documentation). After doing a wizard configuration in my FTP it says I MUST set FTP to passive mode, still having troubles as to how I do that.

    Thoughts?
     
  5. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,895
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @Ally,

    Do you have root access to the system? If so, you need to access the server via the command line as the "root" user in order to make the documented changes to the Pure-FTPd configuration file.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. Mario Rocha

    Mario Rocha Registered

    Joined:
    May 23, 2017
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Managua
    cPanel Access Level:
    Root Administrator
    ports are opened in the firewall. Everything was working fine until the last update for cPanel.
     
  7. Dave Smith

    Dave Smith Active Member

    Joined:
    Mar 20, 2016
    Messages:
    40
    Likes Received:
    12
    Trophy Points:
    8
    Location:
    Lisbon
    cPanel Access Level:
    Root Administrator
    Run in terminal as Root:

    /sbin/modprobe ip_conntrack_ftp
     
  8. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,895
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    Could you open a support ticket using the link in my signature so we can take a closer look? You can post the ticket number here so we can update this thread with the outcome.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. kwdamp

    kwdamp Active Member

    Joined:
    Dec 7, 2017
    Messages:
    28
    Likes Received:
    3
    Trophy Points:
    3
    Location:
    usa
    cPanel Access Level:
    Root Administrator
    Had the same issues, and this fixed it perfectly. Thank you for taking the time to type this out.

    The Passive Port range was there in pure-ftpd.conf from the start, though a slightly higher range.
    But the ports were NOT open in CSF's TCP_IN.

    I added them and it worked immediately. My only question is: was opening the ports some kind of security risk? If not, why were they not there (listed) in the first place?
     
    cPanelMichael likes this.
  10. mtindor

    mtindor Well-Known Member

    Joined:
    Sep 14, 2004
    Messages:
    1,344
    Likes Received:
    58
    Trophy Points:
    178
    Location:
    inside a catfish
    cPanel Access Level:
    Root Administrator
    Any time you have to open a port for inbound/outbound access, the cost of doing so needs to be weighed. Because some admins might not allow FTP or some environments might not allow TCP 20 through corporate firewalls, and because people may set their own preference for passive ports, Chirpy probably figured it was best that the admin actually add the passive ports manually rather than have CSF actually try and guess. Just a hunch.

    If you are a server admin who allows FTP access, then you almost certainly will want to make sure that passive mode is supported.

    I'm glad the post helped you out!

    M
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    cPanelMichael and kwdamp like this.
  11. Samet Chan

    Samet Chan Well-Known Member

    Joined:
    Jun 24, 2016
    Messages:
    351
    Likes Received:
    31
    Trophy Points:
    103
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hi @cPanelMichael , @mtindor ,

    I can still connect to FTP server "Pure-FTP", But I tried to look this and any tutorial won't help. I'd like to enable Pure-FTP firewall to allow IP. I checked in CSF Firewall TCP_IN: there is no for a port in FTP `49152 65534`. I'm confused so. I need to enable FTP firewall to allow IP well.
     
  12. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,895
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    You'd need to add the port range at the end of the existing TCP_IN line. For example:

    Code:
    49152:65534
    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    Samet Chan likes this.
  13. Samet Chan

    Samet Chan Well-Known Member

    Joined:
    Jun 24, 2016
    Messages:
    351
    Likes Received:
    31
    Trophy Points:
    103
    cPanel Access Level:
    Root Administrator
    Twitter:
    Solved problem. Thanks!

    Code:
    Status:    Connecting to xxx.xxx.xxx.xx:21...
    Status:    Connection established, waiting for welcome message...
    Status:    Initializing TLS...
    Status:    Verifying certificate...
    Status:    TLS connection established.
    Status:    Logged in
    Status:    Retrieving directory listing...
    Command:    PWD
    Response:    257 "/" is your current location
    Command:    TYPE I
    Response:    200 TYPE is now 8-bit binary
    Command:    PASV
    Response:    227 Entering Passive Mode (xxx.xxx.xxx.xx,235,111)
    Command:    MLSD
    Error:    The data connection could not be established: ECONNREFUSED - Connection refused by server
    Error:    Connection timed out after 20 seconds of inactivity
    Error:    Failed to retrieve directory listing
    Status:    Disconnected from server
    Using from VPN test it, they will not let connect another IP from SSH/SFTP, FTP it's working now.
     
  14. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,895
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    You're very welcome. I'm glad to see that helped.

    Please open a new thread if you are facing a separate issue with the SSH/SFTP service.

    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. Samet Chan

    Samet Chan Well-Known Member

    Joined:
    Jun 24, 2016
    Messages:
    351
    Likes Received:
    31
    Trophy Points:
    103
    cPanel Access Level:
    Root Administrator
    Twitter:
    Not really, any IP random will not allow connecting to our server. It's working on firewall added for port SFTP/FTP, SSH. You just helpfully me. ;)
     
    cPanelMichael likes this.
  16. Benjamin D.

    Benjamin D. Well-Known Member

    Joined:
    Jan 28, 2016
    Messages:
    116
    Likes Received:
    13
    Trophy Points:
    18
    Location:
    Canada
    cPanel Access Level:
    Root Administrator
    Same problem as described in OP, tried the solution provided on here (tough I only found a /etc/pure-ftpd.conf file, not a /etc/pureftpd.conf file like the solution stated) aand even tough the contents of that conf file was adjusted to PassivePortRange 30000 50000 and that CSF has the TCP_IN [...]30000:50000 rule and that both CSF and Pure-FTPd services were restarted, my FTP client still tries to handshake to a 60000-ish port and fails.

    I also saw that since WHM 60.0 you have to use these instructions. I tried them as well and it's still the same: How to Enable FTP Passive Mode - cPanel Knowledge Base - cPanel Documentation

    What's going on with WHM 72.0 ?
     
  17. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,895
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @Benjamin D.,

    Can you post the output from the following command?

    Code:
    grep PassivePortRange /var/cpanel/conf/pureftpd/local
    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. Benjamin D.

    Benjamin D. Well-Known Member

    Joined:
    Jan 28, 2016
    Messages:
    116
    Likes Received:
    13
    Trophy Points:
    18
    Location:
    Canada
    cPanel Access Level:
    Root Administrator
    PassivePortRange: 30000 50000
     
  19. Benjamin D.

    Benjamin D. Well-Known Member

    Joined:
    Jan 28, 2016
    Messages:
    116
    Likes Received:
    13
    Trophy Points:
    18
    Location:
    Canada
    cPanel Access Level:
    Root Administrator
    I mitigated the issue by opening every TCP_IN, TCP_OUT, IP6_IN and IP6_OUT... Yes, to have it working, it would seem as tough I actually need the OUT ports unlocked too. Not sure why, but now it works reliably... thanks to those tens of thousands of open ports :-/
     
  20. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,895
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello @Benjamin D.,

    You shouldn't have to enable those ports for outgoing connections to allow users to access FTP (via passive mode) on your server from their FTP clients. Have you tried closing the outgoing ports again and confirming that FTP stops working?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice