Using Python 3.3.0 and this script:

from ftplib import FTP_TLS

ftps = FTP_TLS('')
ftps.sendcmd('USER myuname') 
ftps.sendcmd('PASS mypwd')

I get a connection failure due to timeout

>>> ================================ RESTART ================================
    Traceback (most recent call last):
    File "C:\Python33\", line 2, in <module>
      ftps = FTP_TLS('')
    File "C:\Python33\lib\", line 685, in __init__
      FTP.__init__(self, host, user, passwd, acct, timeout, source_address)
    File "C:\Python33\lib\", line 114, in __init__
    File "C:\Python33\lib\", line 148, in connect
    File "C:\Python33\lib\", line 424, in create_connection
      raise err
    File "C:\Python33\lib\", line 415, in create_connection
    TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

But I can connect using a FileZilla client using these credentials. Any clue as to why it times out using a script, but not using Filezilla client?

Did you try ftps = FTP_TLS('', 'myuname', 'mypwd') ?

I did, but it never connects.
After modifying the script to:

from ftplib import FTP_TLS
import ftplib

ftps = FTP_TLS()

ftps.connect(host="", port=990)
ftps.login(user="myuname", passwd="mypwd")


It still times out, but if I comment out the line


It connects fine.

With that line active (uncommented) the Filezilla server log shows this as the problem:

(000050)12/18/2013 12:25:49 PM - myuname (> LIST
(000050)12/18/2013 12:25:49 PM - myuname (> 150 Opening data channel for directory list.
(000050)12/18/2013 12:26:00 PM - myuname (> 425 Can't open data connection.
(000050)12/18/2013 12:28:00 PM - myuname (> 421 Connection timed out.
(000050)12/18/2013 12:28:00 PM - myuname (> disconnected.

So it looks like the LIST command is getting through, but it can't get the data back to my script for some reason

Does ftps.dir() work ?

Apart from that, did you consider connecting to the server through the paramiko module ? Once connected, it is much more user-friendly because the paramiko api was designed for human beings, contrary to the ftp protocol. The hard part may be connection and authentication.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.