Search
Close this search box.

The remote server returned an error: 227 Entering Passive Mode

Today while uploading file to FTP sever, the codes throw an error – “The remote server returned an error: 227 Entering Passive Mode”, after research, I got some knowledge in FTP working principle.

FTP may run in active or passive mode, which determines how the data connection is established.

Active mode:


command connection: client >1024  -> server 21
data connection:    client >1024  <-  server 20

active
passive mode:


command connection: client > 1024 -> server 21
data connection:    client > 1024 <- server > 1024

passive

In active mode, the client connects from a random unprivileged port (N > 1023) to the FTP server’s command port(default port 21). If the client needs to transfer data, the client will use PORT command to tell the server:”hi, I opened port XXXX, please connect to me.” and then server will use port 20 to initiate the data connection to that client port number.

In passive mode, the client connects from a random unprivileged port (N > 1023) to the FTP server’s command port(default port 21). If the client needs to transfer data, the sever will tell the client:”hi, I opened port XXXX , please connect to me.” and then client will initiate the data connection to that sever port number.

In a nutshell, active mode is used to have the server connect to the client, and passive mode is used to have the client connect to the server.

So if your FTP server is configured to work in active mode only or the firewalls between your client and the server are blocking the data port range, then you will get error message, to fix this issue, just set System.Net.FtpWebRequest property UsePassive = false.

Hope this helps!

Thanks for reading!

Tuesday, October 16, 2012 1:55 PM

This article is part of the GWB Archives. Original Author: hmloo’s world

Related Posts