FileZilla – “The data connection could not be established: ECONNREFUSED – Connection refused by server” when retrieving directory listing

filezillafirewallftpnetworking

So a couple of days before, I tried creating a Home FTP Server, which I can access from my own network. It worked. But now I want to go further. I wanted my Home FTP Server accessible from any network via an external IPv4 address. So here is my problem.

Every time if I want to connect to my server on localhost or on my local IP address, it works. But when I try to connect with the same credentials on my external IP address, it says that it cannot retrieve the directory listing:

Status: Connecting to *************:800...
Status: Connection established, waiting for welcome message...
Status: Logged in
Status: Retrieving directory listing...
Command:    PWD
Response:   257 "/" is current directory.
Command:    TYPE I
Response:   200 Type set to I
Command:    PASV
Response:   227 Entering Passive Mode (**,***,*,***,***,106)
Command:    MLSD
Error:  The data connection could not be established: ECONNREFUSED - Connection refused by server
Response:   425 Can't open data connection for transfer of "/"
Error:  Failed to retrieve directory listing

The (obfuscated) IP address in the 227 response does not match the (obfuscated) server IP address in the "Connecting to …" message.

I tried turning off my firewall, forwarded port 21 and port 800 for both TCP and UDP, but nothing worked. I also made exceptions for both ports, and that didn't work as well.

Another problem is, that if I want to log in on my external IP address on my FileZilla Server, it shows this:

Connecting to server -censored-:14147…

Error, could not connect to server

Trying to reconnect in 5 seconds

My question is: how do I create a Home FTP Server which is can access remotely?

Best Answer

Response:   227 Entering Passive Mode (**,***,*,***,***,106)
Command:    MLSD
Error:  The data connection could not be established: ECONNREFUSED - Connection refused by server

If the IP address in the 227 response to the PASV command does not match the actual FTP server IP address, the server is misconfigured.

This usually happens, when the server is not aware of its external IP address and reports its internal IP address. But most FTP clients (including FileZilla) would be able to detect that by checking the IP address against a range of addresses reserved for local communications within a private network. See Server sent passive reply with unroutable address in FileZilla. As that did not happen, the server is probably explicitly configured with an incorrect IP address.

For generic information, see my article about network configuration needed for FTP.

You have to reconfigure the FTP server to the new IP address. In FileZilla FTP server you can do that by going to Edit > Settings > Passive mode settings > IPv4 specific > External Server IP Address for passive transfers in FileZilla Server Interface.

Related Topic