I get this problem report almost daily: "My application works fine on my development machine, but when I move it to the (web) server the FTP no longer works." I then ask for the ftp2.LastErrorText information, see that it’s Active mode, suggest setting the Passive property to true, and the problem is solved. Here’s why:
In FTP, commands are sent over a control connection (port 21 usually) and each data transfer happens on a separate TCP/IP connection. The process of establishing the data connection differs with Passive and Active modes.
Active Mode: The FTP client chooses a port number and sends a "PORT" command to the FTP server. The FTP client then listens at the chosen port and the FTP server issues a connect request to establish the connection. The data connection is outgoing from the FTP server, and incoming to the FTP client.
Passive Mode:The FTP client sends a PASV command to the FTP server. The FTP server chooses a port number and sends it in the PASV response. The FTP server then listens at that port for the incoming connect request from the FTP client. The data connection is incoming to the FTP server, and outgoing from the FTP client.
This is the typical situation: Your development computer is not behind a firewall that is blocking the incoming data connection request from the FTP server. Therefore, Active mode works. However, when you deploy your application to your web server, it is now behind a firewall that blocks the incoming data connection. Changing the mode to Passive inverts the data connection so that it is initiated from the FTP client to the FTP server. The data connection request is outgoing from your web server, and thus everything works — unless of course your FTP server is blocking incoming connections… in which case you’re SOL unless one side opens up some ports and lets something through…