I need to transfer files from Rpi to my computer. Rpi is connected to my computer with wifi. The FileZilla server is logged in into. But in the terminal when I run the FTPlib file I get this error: " socket.error: [Errno 111] Connection refused

import ftplib
server = ''
username = 'localhost'
password = 'hello123'
ftp_connection = ftplib.FTP(server, username, password)
remote_path = "C:\Users\sai\Desktop\ImageS"
fh = open("/home/pi/Desktop/ImageS/test.txt", 'rb')
ftp_connection.storbinary('STOR test.txt', fh)
  • Comments are not for extended discussion; this conversation has been moved to chat. Please note that all relevant information (including that solicited by comments) should be edited into the question body itself. Please do not expect the readers of your question to follow a long trail of comments to gather what is relevant to give an answer. Thanks.
    – Ghanima
    Commented Dec 13, 2017 at 22:25

1 Answer 1


Your code does work with FileZilla in principal, I've just run it up on a Windows VM with FileZilla Server and a Pi with Python3. You'll need some configuring though.

server needs to be the IP address of the FTP server

The username and password need to be the ones configured in FileZilla settings. These are not the same ones as the 'admin interface' ones. Go to edit / users in the menu bar and add yourself a user, password and set a directory to act as their home /. The home directory is where you'll end up when you connect. You may want to grant write permissions to this too.

in edit /settings leave port 21 in place and go to the passive mode settings and configure a port range. I used 50000->50100 since I don't have anything there.

You'll also need to configure the Windows firewall to accept traffic on port 21 and the same range of other ports for Passive mode.

the remote_path variable needs to be based on the home you set for the user. So say you set the home to c:\ftp and you wanted the files in c:\ftp\dogs you set remote_path to /dogs (note the slashes don't mix to well between Linux and Windows).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.