A
A
Alexander Ananchenko2021-09-08 14:50:19
Python
Alexander Ananchenko, 2021-09-08 14:50:19

Python FTP can't connect how to solve?

And so I try to connect to my host via FTP, the programs all work with my host, but I need to go to the hosting via FTP

from ftplib import FTP

ftp = FTP()
connect = ftp.connect(HOST, IP)
login = ftp.login(USER, PASS)
print(connect)
print(login)
data = ftp.retrlines('LIST')
 
print(data)


I tried to connect in different ways, as a result I get the error

ConnectionResetError: [WinError 10054] The remote host forcibly terminated the existing connection

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Ananchenko, 2021-09-08
@Shurik24

And so the problem was on the host side, after 4 hours of waiting I got the answer, "Restart hosting, should help", and in the end yes it helped, thanks to everyone who tried to help!

V
Vindicar, 2021-09-08
@Vindicar

You have: connect = ftp.connect(HOST, IP )
In the docks: FTP.connect(host='', port =0, timeout=None, source_address=None)
Is this a typo, or is there such a mistake in the code?

A
Aleksandr, 2021-09-08
@QQQ-RRR

This is how it should work

from ftplib import FTP

ftp = FTP(host)
ftp.login('your_username' , 'your_password')
ftp.retrlines('LIST')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question