FTP

FTP port guide: file transfer on ports 20 and 21

Understand how FTP control and data connections work, why passive port ranges matter, and why SFTP or FTPS is usually safer for new file-transfer workflows.

Default port
20/21
Protocol
TCP
Primary use
Legacy file transfer

What is the FTP port?

FTP, or File Transfer Protocol, is a legacy protocol for uploading and downloading files. FTP usually uses TCP port 21 for the control connection. In active FTP, TCP port 20 may be used for data from the server; in passive FTP, the server opens a configured passive data port range.

  • Port 21 is the FTP control port

    Clients connect to TCP 21 to authenticate, list directories, request uploads, request downloads, and negotiate how the data connection will be opened.

  • Data ports depend on active or passive mode

    FTP is harder to firewall than modern protocols because file data often travels over a separate connection from commands.

How FTP works

FTP separates commands from file data. The client connects to the server on TCP 21, logs in, and sends commands such as list, retrieve, store, rename, or delete. File listings and transfers then use a separate data connection.

That design made sense in older networks, but it creates problems with NAT, firewalls, and cloud security groups. A port checker can show whether port 21 is reachable, but a successful file transfer also depends on the data channel being allowed.

Active FTP vs passive FTP

In active FTP, the client connects to the server's control port, then the server opens a data connection back to the client. That reverse connection often fails through NAT or strict client firewalls.

In passive FTP, the client opens both the control connection and the data connection to the server. Passive mode is more common for internet-facing FTP, but the server must publish a defined passive port range and firewalls must allow that range.

FTP vs FTPS vs SFTP

Plain FTP does not encrypt usernames, passwords, commands, or file contents. FTPS adds TLS to FTP, but it still keeps the FTP control and data-channel model. SFTP is different: it runs over SSH, usually on TCP 22, and does not use FTP ports.

For new deployments, SFTP is often simpler to firewall and operate. FTPS may be required for partner compatibility. Plain FTP should be limited to isolated legacy workflows or replaced when possible.

When FTP should be open

Open FTP only when a legacy partner, device, application, or workflow cannot use SFTP, FTPS, HTTPS upload, object storage, or a managed file-transfer service. Common examples include older EDI feeds, scanners, embedded devices, and vendor integrations.

Avoid public anonymous FTP unless it is intentionally serving public files and has tight upload controls. Writable FTP exposed to the internet is frequently abused for malware staging, data theft, and storage misuse.

Before opening FTP

Before allowing FTP, decide whether the server will use active mode, passive mode, or both. Define the passive port range, external IP address, user isolation model, chroot or jail behavior, logging, quotas, and whether TLS is required.

A TCP check against port 21 confirms only the control path. Test real uploads and downloads from outside the network because passive range, NAT, TLS inspection, and filesystem permissions can still break transfers.

How to enable FTP on Windows, Linux, and cloud servers

On Windows Server, IIS FTP can provide FTP or FTPS. Configure user isolation, TLS policy, passive port range, firewall rules, and external IP settings if the server is behind NAT.

On Linux, servers such as vsftpd, ProFTPD, and Pure-FTPd are common. Configure local users or virtual users, chroot behavior, passive port range, TLS certificates if using FTPS, and host firewall rules for TCP 21 plus the data ports.

On cloud servers, allow only the required sources where possible. Open TCP 21 and the passive range in the cloud security group and host firewall. If you cannot define a narrow passive range, FTP will be difficult to secure cleanly.

  • Control path: clients must reach TCP 21.
  • Data path: passive FTP requires a server-side passive port range; active FTP may require server-to-client connections.
  • Identity layer: use named accounts, least privilege, chroot or user isolation, and strong credentials.
  • Migration layer: document why FTP remains and plan a move to SFTP, FTPS, HTTPS upload, or managed transfer.

How to test FTP ports

Start with an external port check for TCP 21. If the control port is open, test with a real FTP client from outside the network. Confirm login, directory listing, upload, download, rename, and delete behavior as appropriate.

If login works but directory listing or transfers hang, inspect passive mode settings, passive port range, external IP advertisement, NAT, cloud security groups, and TLS settings. Many FTP failures are data-channel failures, not port 21 failures.

Test port 21 for FTP

Common FTP troubleshooting cases

If port 21 is closed, the FTP service may be stopped, bound to a private interface, blocked by a host firewall, or denied by a cloud security group. If port 21 is open but transfers fail, passive ports or NAT are the first places to check.

If authentication fails, inspect username format, password policy, account lockout, chroot permissions, filesystem ownership, TLS requirement, and server logs. If only some clients fail, compare active vs passive mode and whether the client is behind restrictive NAT.

Security checklist for FTP

Avoid plain FTP for credentials or private files. Use FTPS or SFTP when possible, disable anonymous upload, restrict source IPs, isolate users, set quotas, and keep detailed transfer logs.

If FTP must remain public, patch the server, limit passive ports, monitor failed logins and upload volume, scan uploaded files, and remove stale accounts. Treat FTP as a legacy exception with an owner and migration plan.

Frequently asked questions

What ports does FTP use?

FTP uses TCP port 21 for the control connection. Active FTP may use TCP 20 for server-side data connections, while passive FTP uses a configured server-side passive port range.

Is FTP secure?

Plain FTP is not secure because it does not encrypt credentials or file contents. Use SFTP or FTPS for sensitive transfers.

Why is FTP port 21 open but transfers fail?

The control connection may work while the data connection is blocked. Check passive mode, passive port range, NAT, external IP settings, firewalls, and TLS policy.

Is SFTP the same as FTP?

No. SFTP is a different protocol that runs over SSH, usually on TCP 22. FTP uses port 21 and separate data connections.