1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python FTPS upload error: 425 Unable to build data connection: Operation not permitted

Discussão em 'Python' iniciado por Stack, Setembro 8, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to use ftps to send a file to a FTP server. Login and changing directory work:

    import ftplib
    ftps = ftplib.FTP_TLS('host','user','pwd')
    ftps.set_pasv(True)
    ftps.prot_p()
    ftps.cwd('/target_directory')


    however when I try to upload my file:

    file = open(file, 'rb')
    send_cmd = 'STOR file_name.txt'
    ftps.storbinary(send_cmd, file)
    file.close()
    ftps.quit()


    I get the following error:

    File "/script/location/script.py", line 161, in <module>
    ftps.storbinary(send_cmd,file)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ftplib.py", line 772, in storbinary
    return self.voidresp()
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ftplib.py", line 229, in voidresp
    resp = self.getresp()
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ftplib.py", line 222, in getresp
    raise error_temp, resp
    ftplib.error_temp: 425 Unable to build data connection: Operation not permitted


    I've read that the 425 response code is often a result of being in active mode, which is why I included ftps.set_pasv(True) (although this is True by default).

    I've also tried just listing the directory contents using ftps.retrlines('LIST') but get essentially the same error. I'm using Python 2.7.10. Any help would be greatly appreciated.

    Continue reading...

Compartilhe esta Página