Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component

Index of Chilkat Blog Posts

August 27, 2007

Active vs. Passive FTP

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…

Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.