Python FTP: "TimeoutError: [Errno 110] Connection timed out" but I can connect with sftp in terminal
Question:
I’m getting error while connecting to FTP in Python:
server.connect('68.183.91.171')
File "/usr/lib/python3.6/ftplib.py", line 152, in connect
source_address=self.source_address)
File "/usr/lib/python3.6/socket.py", line 724, in create_connection
raise err
File "/usr/lib/python3.6/socket.py", line 713, in create_connection
sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out
My code:
import ftplib
server = ftplib.FTP()
server.connect('68.183.91.171')
server.login('root','password')
server.dir()
I think the connection settings are correct as I can connect in terminal with
sftp 68.183.91.171
Answers:
I’m getting error while connecting to FTP in Python:
server.connect('68.183.91.171')
File "/usr/lib/python3.6/ftplib.py", line 152, in connect
source_address=self.source_address)
File "/usr/lib/python3.6/socket.py", line 724, in create_connection
raise err
File "/usr/lib/python3.6/socket.py", line 713, in create_connection
sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out
My code:
import ftplib
server = ftplib.FTP()
server.connect('68.183.91.171')
server.login('root','password')
server.dir()
I think the connection settings are correct as I can connect in terminal with
sftp 68.183.91.171