The requested address is not valid in its context

Introduction Facing this issue with Python2.7 and Ftplib ? I won’t waste your time talking shit! Let’s fix it. Create a new class inheriting Ftplib’s FTP_TLS class. import ftplib class FTP_TLS_UNROUTABLE_HOST(ftplib.FTP_TLS, object): def makepasv(self): _, port = super(FTP_TLS_UNROUTABLE_HOST, self).makepasv() return self.host, port Now, use this new class to create a new session. session = FTP_TLS_UNROUTABLE_HOST('host','username','password') Now ? Do whatever you want with your session :) It won’t cry for The requested address is not valid in its context....

November 15, 2017 · 1 min · Sourav Badami