ftp automation

ScriptFTP

The professional tool to automate FTP, SFTP, FTPS and schedule FTP batch jobs

The forum is now read only. Please, go to the the main ScriptFTP website if you need help.
Post here if you experience file transfer problems or unexpected errors.
Hi,

I got the above error for this 1 FTP server quite often:-
No connection could be made because the target machine actively refused it.
425 Can't open data connection.

ScriptFTP works fine for the first few file download, but somehow, it got an error.

TIA

Johnny
===== OUTPUT =====
DELETEFILE("20080818796001.A.edi")
PASV
227 Entering Passive Mode (210,187,30,9,7,68).
Opening data connection to 210.187.30.9 Port: 1860
LIST
125 Data connection already open; Transfer starting.
1830 bytes transferred. (9.50 KB/s) (188 ms)
226 Transfer complete.

Deleting remote file.......... 20080818796001.A.edi
DELE 20080818796001.A.edi
250 DELE command successful.
CWD /mis/OUT
250 CWD command successful.
PWD
257 "/mis/OUT" is current directory.

SUCCESSFUL! File Saved.

GETFILE("20080818796027.D.edi")
PASV
227 Entering Passive Mode (210,187,30,9,7,69).
Opening data connection to 210.187.30.9 Port: 1861
LIST
125 Data connection already open; Transfer starting.
1769 bytes transferred. (9.18 KB/s) (188 ms)
226 Transfer complete.

Downloading................. 20080818796027.D.edi
SIZE 20080818796027.D.edi
213 5852
PASV
227 Entering Passive Mode (210,187,30,9,7,70).
Opening data connection to 210.187.30.9 Port: 1862
RETR 20080818796027.D.edi
125 Data connection already open; Transfer starting.
5852 bytes transferred. (13.0 KB/s) (438 ms)
226 Transfer complete.
CWD /mis/OUT
250 CWD command successful.
PWD
257 "/mis/OUT" is current directory.


DELETEFILE("20080818796027.D.edi")
PASV
227 Entering Passive Mode (210,187,30,9,7,71).
Opening data connection to 210.187.30.9 Port: 1863
LIST
125 Data connection already open; Transfer starting.
1769 bytes transferred. (12.2 KB/s) (141 ms)
226 Transfer complete.

Deleting remote file.......... 20080818796027.D.edi
DELE 20080818796027.D.edi
250 DELE command successful.
CWD /mis/OUT
250 CWD command successful.
PWD
257 "/mis/OUT" is current directory.

SUCCESSFUL! File Saved.

GETFILE("20080818796193.D.edi")
PASV
227 Entering Passive Mode (210,187,30,9,7,72).
Opening data connection to 210.187.30.9 Port: 1864
LIST
No connection could be made because the target machine actively refused it.
425 Can't open data connection.

***** GETFILE Error #425: Cannot read remote file listing of /mis/OUT.
***** The server said: Can't open data connection.

CWD /mis/OUT
250 CWD command successful.
PWD
257 "/mis/OUT" is current directory.

ERROR! Cannot Save File To Local Directory.
Hi Johny,

It seems to be a firewall problem. Try putting this command on the top of your script file:
FTP Script
  1. SETPASSIVE(DISABLED)
If it still does not work we have to investigate a little further:
227 Entering Passive Mode (210,187,30,9,7,72).
Opening data connection to 210.187.30.9 Port: 1864
LIST
No connection could be made because the target machine actively refused it.
425 Can't open data connection.

***** GETFILE Error #425: Cannot read remote file listing of /mis/OUT.
***** The server said: Can't open data connection.
Your FTP server is telling ScriptFTP to connect to its port number 1864 in order to retrieve the file listing (ScriptFTP requests it before starting the file transfer) but it seems that the port 1864 on your FTP server is not accessible. This error is often related to a firewall in the network path between ScriptFTP and the FTP server, usually the firewall installed on the server machine or in a router within the same network. I suggest you to do the following:

- Find a range of TCP ports on the server that you know that can be reached. To get this known range configure the firewalls accordingly or simply try many times with ScriptFTP and write down the TCP ports that seem to work.

- Configure your FTP server (if possible) to use this range of ports. This is often called server port range in the FTP server configuration.

Please, post here any result you may get and feel free to write any further questions.
Thanks for the reply.

I hv change to set SETPASSIVE( DISABLED ) and seems to be working fine on the wireless at the office.

I will test again on the PRODUCTION environment to see if it works.

Again, i understand that certain ports > 1024 needed to be open. And therefore, it will a little bit of a issue.

I thought normally, FTP just uses Port 21 and 20? How come we need to enable ports > 1024?
Hi Johny,
I thought normally, FTP just uses Port 21 and 20?
Yes, this is true for the FTP mode called active (the one that seems to work in your network). It goes through the server's port 21 and, for file transfers, the server connects to the client's port number 20.

For being more firewall friendly it was developed the FTP passive mode, which is the most common mode and the default one in ScriptFTP. The clients connects to the server port number 21 (like the other mode) and, when the client requests a file transfer, the FTP server tells the client to connect to a specified server's port to transfer the the file contents. You have to set in the FTP server configuration the range of ports to give the clients to connect. By default most FTP servers use a range that starts >1024 but the network administrators usally change this range to one that works in that network.
How come we need to enable ports > 1024?
>1024 is not mandatory, it's only an example. You can set in the FTP server configuration the range of ports you want, for example, from 200 to 220, another common range is from 1024 to 1228. The only standard port in the FTP protocol is the server's port 21, the one used by the FTP clients to authenticate and exchange commands with the server. The contents of the files are transfered using other ports and depend on the mode used (active or passive) and the FTP server configuration (as I explained above).