---
title: "Active vs passive FTP: how the data connection works · CloudSat"
description: "Active and passive FTP explained: PORT, PASV and EPSV step by step, why NAT breaks active mode, how TLS changes firewall rules, and passive setup for vsftpd."
url: https://cloudsat.io/learn/active-vs-passive-ftp-explained
updated: 2026-11-18T12:00:00Z
source: CloudSat (https://cloudsat.io/). Prices in USD.
---

[Networking](https://cloudsat.io/learn/topic/networking-and-dns)

# Active vs passive FTP: how the data connection works

Active and passive FTP explained: PORT, PASV and EPSV step by step, why NAT breaks active mode, how TLS changes firewall rules, and passive setup for vsftpd.

CloudSat team November 18, 2026 6 min read

FTP is older than firewalls, and it shows. Every session uses two TCP connections: one for commands and a fresh one for each directory listing or file transfer. "Active" and "passive" describe who opens that second connection. Get it wrong and you see the classic symptom: the login succeeds, then the directory listing hangs until it times out. This guide walks through both modes at the packet level, shows why passive mode won, and gives working passive settings for common servers.

## Two connections, not one

The **control connection** goes from the client to the server's port 21 and stays open for the whole session. Commands such as `USER`, `PASS`, `LIST`, `RETR` and `STOR` travel over it, and the server answers with numbered replies such as `230` for a successful login.

The **data connection** is opened for each listing and each file, then closed. Its direction is the whole difference between the two modes.

## Active mode, step by step

1. The client connects from a random high port to port 21 on the server and logs in.
2. The client starts listening on a port of its own and tells the server where to find it: `PORT 192,0,2,15,195,80`. The first four numbers are its IPv4 address, the last two encode the port.
3. The server opens the data connection **from its port 20 to the client's port 50000**.

For IPv6 the client sends `EPRT |2|2001:db8::15|50000|` instead, with the address family, address and port in plain text.

Active mode made sense when every computer had a public address and no firewall. Today it fails in two ways. The client's firewall usually drops the unexpected inbound connection from the server. And a client behind NAT advertises its private address in the `PORT` command, so the server tries to connect to an address that does not exist on the internet.

## Passive mode, step by step

1. The control connection opens exactly as before.
2. The client sends `PASV`. The server picks a port, starts listening on it, and replies `227 Entering Passive Mode (203,0,113,10,195,80)`.
3. The client opens the data connection **to 203.0.113.10 on port 50000**.

The extended form, `EPSV`, answers `229 Entering Extended Passive Mode (|||50000|)`. It carries only a port, and the client reuses the address of the control connection. That works over IPv6 and avoids the problem of a server announcing the wrong address.

Now the client only makes outbound connections, which every home router and office firewall allows. The burden moves to the server: it must accept inbound connections on its passive ports and announce an address the client can actually reach.

## Decoding the port numbers

The last two numbers in `PORT` and `227` replies are the port split into two bytes:

| Reply fragment | Calculation | Port |
| --- | --- | --- |
| `195,80` | 195 × 256 + 80 | 50000 |
| `156,64` | 156 × 256 + 64 | 40000 |
| `0,21` | 0 × 256 + 21 | 21 |

When a client log shows `227 Entering Passive Mode (10,0,0,5,...)`, the server is announcing a private address, and remote clients will never connect. That single line explains a large share of FTP support tickets.

## Active and passive side by side

|  | Active | Passive |
| --- | --- | --- |
| Data connection opened by | Server, toward the client | Client, toward the server |
| Commands | `PORT`, `EPRT` | `PASV`, `EPSV` |
| Server firewall | Inbound 21, outbound from 20 | Inbound 21 plus the passive range |
| Client firewall | Must accept inbound connections | Outbound only |
| Client behind NAT | Usually breaks | Works |
| Default in current clients | No | Yes |

## Firewalls, NAT helpers and TLS

Stateful firewalls can follow FTP by reading the control connection and opening data ports on the fly. Linux has the `nf_conntrack_ftp` helper and Windows Firewall has a stateful FTP filter. Two things undermine that approach. Recent Linux kernels no longer attach the FTP helper to connections automatically, so it has to be enabled with explicit rules. And FTPS encrypts the control connection, so no helper can read the port numbers any more.

The dependable setup therefore ignores helpers entirely: give the server a fixed passive range, open that range explicitly, and set the address the server announces.

## Configure passive mode on a Linux server

For vsftpd, add these lines to `/etc/vsftpd.conf`, along with the paths to your certificate and key in `rsa_cert_file` and `rsa_private_key_file`:

```ini
pasv_enable=YES
pasv_min_port=40000
pasv_max_port=40100
pasv_address=203.0.113.10
ssl_enable=YES
force_local_logins_ssl=YES
force_local_data_ssl=YES
```

ProFTPD uses two directives in `proftpd.conf`:

```text
PassivePorts 40000 40100
MasqueradeAddress 203.0.113.10
```

The announced address setting matters only when the server sits behind NAT. On a server whose public address is configured on its own interface, the default answer is already correct. Then open the control port and the range in the host firewall:

```bash
sudo ufw allow 21/tcp
sudo ufw allow 40000:40100/tcp
sudo systemctl restart vsftpd
```

Open the same two entries in any firewall in front of the server. A CloudSat [cloud firewall](https://cloudsat.io/docs/cloud-firewalls) accepts a port range in a single rule, so the passive range is one line. On Windows with IIS, the equivalent settings live in **FTP Firewall Support**, covered in the guide to [running FTPS on Windows](https://cloudsat.io/learn/iis-ftps-server-windows).

## Choose the mode in the client

- **FileZilla:** passive is the default under the FTP connection settings, and each saved site can override it in **Transfer Settings**.
- **curl:** passive by default. `--ftp-port -` switches to active mode using the same local address as the control connection.
- **lftp:** passive by default; `set ftp:passive-mode off` switches.
- **Windows `ftp.exe`:** active only. Microsoft's own IIS documentation notes that this client does not support passive connections.

Current versions of Chrome and Firefox no longer open `ftp://` links at all, so use a dedicated client.

## Troubleshoot by symptom

| Symptom | Likely cause |
| --- | --- |
| Login works, listing hangs | Passive range blocked, or the server announces a private address |
| `425 Can't open data connection` | The data connection failed in whichever direction the mode requires |
| Works without TLS, fails with TLS | A firewall helper was doing the work; open the passive range explicitly |
| Active mode works only on the office network | The client's NAT or firewall drops the server's inbound data connection |

## FAQ

### Is passive FTP more secure than active?

No. The mode only decides who opens the data connection. Neither mode encrypts anything. For security, use FTPS (FTP over TLS) or switch to SFTP, which runs over SSH on a single port.

### What is port 20 used for?

It is the server's source port for data connections in active mode. Passive mode does not use it, so a passive-only server does not need any rule for port 20.

### Why does my client sometimes switch to active mode on its own?

Some clients, FileZilla among them, can fall back to the other mode when a data connection fails. That hides the real problem and produces transfers that work on one network and not on another. Turn the fallback off while you troubleshoot, fix the passive range or the announced address, then leave passive mode as the only mode.

### How large should the passive range be?

Each concurrent listing or transfer holds one port while it runs. A range of 100 ports suits a small team; widen it for busy servers and keep every firewall rule in step with the server setting.

**Run it on CloudSat.** Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. [See plans](https://cloudsat.io/plans) or [deploy a server](https://dash.cloudsat.io/console/deploy).

## Keep reading

[All guides in Networking](https://cloudsat.io/learn/topic/networking-and-dns)

- [Set up a secure FTP server on Windows with IIS and FTPS](https://cloudsat.io/learn/iis-ftps-server-windows): Networking Set up a secure FTP server on Windows with IIS and FTPS 6 min read
- [UFW, firewalld or nftables: choosing a Linux server firewall](https://cloudsat.io/learn/ufw-firewalld-nftables-compared): Security UFW, firewalld or nftables: choosing a Linux server firewall 7 min read
- [Check open and listening ports on Linux with ss and lsof](https://cloudsat.io/learn/list-listening-ports-linux): Networking Check open and listening ports on Linux with ss and lsof 6 min read
- [FTP vs FTPS vs SFTP: which file transfer protocol to use](https://cloudsat.io/learn/ftp-ftps-or-sftp-which-to-use): Networking FTP vs FTPS vs SFTP: which file transfer protocol to use 6 min read
