FTP "425 Can't open data connection" only happens when using command prompt

8

1

All of my computer are behind a single router. I have a FileZilla server running on one of them. I am trying to automate an upload to the server using a batch script and Window's built-in ftp.exe. I have set up a dynamic DNS service to be able to access my server from outside the router and I have set up port forwarding in the router to my server. I can connect and transfer just fine using Google Chrome, Windows Explorer, and the FileZilla client. However, whenever I try using ftp.exe (either manually or in batch script) I can connect to the server but if I try doing anything that would open a data connection (LIST, STOR, or RETR) I get the following error: 425 Can't open data connection. I have allowed ftp.exe in both computer's firewalls. Any ideas what is going on or how I could fix it? I don't need to use ftp.exe if anyone knows of a portable independent (just an exe with no other files) command line client.

EDIT I know that my ISP blocks many ports including 21 and several others in that range. This is all set up on port 2121, with the passive ports set up to be 2122-2142, all of these have been forwarded in the router. Perhaps ftp.exe will only use a certain port for data connection, which my ISP blocked? If so how would I change this?

Garrett

Posted 2012-04-13T11:41:39.603

Reputation: 386

Answers

5

Regular active FTP uses a separate server-initiated data connection for transfers and only uses the regular port 21 connection as the control channel. When the client is behind a firewall, however, the firewall is likely to block this connection. I'm guessing Chrome, Explorer, FireZilla, etc. are smart enough to try passive mode, in which the original client-initiated connection is used as both the control and data channel.

It appears that Windows' default CLI FTP client doesn't support passive mode. So you'll need to switch to NcFTP. Alternatively, and I think probably the better option, is just to use SFTP instead. FTP is insecure and really only to be used on LANs. SFTP is fully encrypted and also only uses a single channel for data and commands. If you need a CLI SFTP client, PSFTP is a good option.

Lèse majesté

Posted 2012-04-13T11:41:39.603

Reputation: 3 129

I have already tried that with no luck – Garrett – 2012-04-13T11:58:07.493

@Garrett: Hrmm... it appears that the blog article I linked to is wrong, and the default CLI FTP client doesn't support passive mode. In that case, you'll have to switch FTP clients. NcFTP is one option, and it definitely supports passive mode.

– Lèse majesté – 2012-04-13T12:03:43.597

I watched the request/response while transferring through Windows Explorer, used quote to manually send the exact same commands, yet still got the same error – Garrett – 2012-04-13T12:03:52.633

@Garrett: I thought Windows Explorer worked? If the client doesn't support passive mode, then telling the server to switch to it won't matter. – Lèse majesté – 2012-04-13T12:06:37.510

Does it support command line, and is it an independent exe? – Garrett – 2012-04-13T12:06:45.283

yes I watched windows explorer, then in the command line used quote to send the same commands windows explorer used – Garrett – 2012-04-13T12:07:40.070

@Garrett: Ah, sorry, I misunderstood you. And, yes, NcFTP is run frm the command line. I'm not sure it's an independent .exe file though. I'll have to look into whether or not there's a portable way to run it. PSFTP should be portable though, but it's for SFTP only. – Lèse majesté – 2012-04-13T12:12:46.893

IT WORKS!!! Thank you so much I have been working on this problem for 3 full days doing literally noting else but eating and barely sleeping! – Garrett – 2012-04-13T12:30:08.310

0

Windows FTP CLI does support PASSIVE mode. Use "quote pasv" to enter into passive mode.

George Rios

Posted 2012-04-13T11:41:39.603

Reputation: 17

2I don't think that actually works. Can you confirm that quote pasv actually does something in ftp.exe and isn't just a dummy command? – Lèse majesté – 2013-10-01T09:28:46.087

0

I had this problem as well. The solution was stop the firewall of the antivirus (in my case the McAfee), it was blocking the ports of FTP.

Sfalcini

Posted 2012-04-13T11:41:39.603

Reputation: 1

That's not really a solution. – ivan_pozdeev – 2017-09-15T08:12:04.583