I have a local FTP server set up on my machine. It's set up on 127.0.0.1 and port 21. When I'm trying to access it using the python-based library ftplib
, the program is throwing an error. This is the code that I'm running.
from ftplib import FTP
ftp = FTP("ftp://127.0.0.1", user = "VAIBHAV", passwd = "12345")
ftp.dir()
ftp.retrlines("LIST")
ftp.quit()
And, this is the error.
Traceback (most recent call last):
File ".\main.py", line 5, in <module>
ftp = FTP("ftp://127.0.0.1", user = "VAIBHAV", passwd = "12345")
File "C:\Users\VAIBHAV\AppData\Local\Programs\Python\Python38\lib\ftplib.py", line 117, in __init__
self.connect(host)
File "C:\Users\VAIBHAV\AppData\Local\Programs\Python\Python38\lib\ftplib.py", line 152, in connect
self.sock = socket.create_connection((self.host, self.port), self.timeout,
File "C:\Users\VAIBHAV\AppData\Local\Programs\Python\Python38\lib\socket.py", line 787, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Users\VAIBHAV\AppData\Local\Programs\Python\Python38\lib\socket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed
How should I fix this error?
I'm using python 3.8.7 and I have Windows 10 on my machine.