0

I have an ftp server deployed on aws. I can connect to it from FileZilla as well as from the command line. However, the python script I have gives me:

OSError: [Errno 101] Network is unreachable

I know that my script works since I can connect to other servers.

def test_connection():
   server = ftplib.FTP()
   server.connect('xx.xxx.xxx.xx')
   server.login('xxxx', 'xxx')
   print(server.dir())
   server.quit()

if __name__ == "__main__":
   test_connection()

Any clues what this could be ?

Many thanks :)

AzyCrw4282
  • 7,222
  • 5
  • 19
  • 35
saiftyfirst
  • 111
  • 2
  • 7

2 Answers2

0

You may want to restructure your code so that credentials are initialized in the FTP constructor call.

import ftplib
server= ftplib.FTP('server.address.com','USERNAME','PASSWORD')
print(server.dir())
session.quit()

Use ftplib.FTP_TLS instead if you FTP host requires TLS.

AzyCrw4282
  • 7,222
  • 5
  • 19
  • 35
0

What worked in the end:

I changed the vsftpd config:

listen=YES listen_ipv6=NO

Not exactly sure though what the problem is

saiftyfirst
  • 111
  • 2
  • 7
  • Can you elaborate on this? Im having the same issue. Where is that config, in ftplib? What is it? – Dariusz Jun 17 '22 at 10:21