{"id":364,"date":"2026-10-31T09:45:00","date_gmt":"2026-10-31T09:45:00","guid":{"rendered":"https:\/\/backendside.com\/blog\/?p=364"},"modified":"2026-11-21T11:30:04","modified_gmt":"2026-11-21T11:30:04","slug":"active-vs-passive-ftp-firewalls-nat","status":"publish","type":"post","link":"https:\/\/backendside.com\/blog\/2026\/10\/31\/active-vs-passive-ftp-firewalls-nat\/","title":{"rendered":"Active vs Passive FTP: Firewalls, NAT and Why Connections Hang"},"content":{"rendered":"<p class=\"lead\">It is one of the most familiar failures in IT: the FTP client connects, the login succeeds, and then&hellip; nothing. The directory listing spins, times out, or the client reports &ldquo;Failed to retrieve directory listing&rdquo;. The password is fine and the server is up. The culprit is almost always the same thing &mdash; FTP&rsquo;s separate <strong>data channel<\/strong> running into a firewall or a NAT router. Once you understand how active and passive mode open that channel, the fix is usually a two-line configuration change.<\/p>\n<h2>Why FTP needs a second connection<\/h2>\n<p>FTP predates firewalls and NAT. It uses one TCP connection, the <strong>control channel<\/strong> on port 21, for commands like <code>USER<\/code>, <code>CWD<\/code> and <code>RETR<\/code>. Every time it needs to move actual data &mdash; a file, or even just a directory listing &mdash; it opens a <strong>brand-new TCP connection<\/strong> for that one job. The two modes differ only in <em>who opens that second connection, and to which port<\/em>.<\/p>\n<p>That is why logins work while listings hang: logging in uses only the control channel. The first time the data channel is needed is when you ask to see a folder.<\/p>\n<h2>Active mode: the server calls you back<\/h2>\n<p>In active mode, the client tells the server &ldquo;connect back to me here&rdquo; with a <code>PORT<\/code> command, and the server opens the data connection <em>from<\/em> its port 20 <em>to<\/em> the client:<\/p>\n<pre style=\"background:#1e1d1b;color:#eceae6;padding:1rem 1.15rem;border-radius:8px;overflow-x:auto;font-size:.85rem;line-height:1.5;\"><code>Client 192.168.1.50:52000  --&gt;  Server :21      (control)\nPORT 192,168,1,50,203,20                         (= port 203*256+20 = 51988)\n200 PORT command successful\nLIST\nServer :20  --&gt;  Client 192.168.1.50:51988       (data, server-initiated)<\/code><\/pre>\n<p>Two things go wrong here on modern networks:<\/p>\n<ul>\n<li><strong>The client&rsquo;s firewall<\/strong> (Windows Defender Firewall, a corporate perimeter) sees an unsolicited <em>inbound<\/em> connection and drops it.<\/li>\n<li><strong>NAT<\/strong>: the client advertised its private address <code>192.168.1.50<\/code>. The server cannot route to that from the internet, so the connection goes nowhere.<\/li>\n<\/ul>\n<p>Active mode works well only when the client has a public address or sits on the same network as the server. For a laptop behind a home router, it is nearly always the wrong choice.<\/p>\n<h2>Passive mode: you call the server twice<\/h2>\n<p>In passive mode the client sends <code>PASV<\/code> (or <code>EPSV<\/code>), the server picks a port, and the client opens the data connection outbound:<\/p>\n<pre style=\"background:#1e1d1b;color:#eceae6;padding:1rem 1.15rem;border-radius:8px;overflow-x:auto;font-size:.85rem;line-height:1.5;\"><code>PASV\n227 Entering Passive Mode (203,0,113,10,195,80)  (= 203.0.113.10 port 195*256+80 = 50000)\nLIST\nClient  --&gt;  Server 203.0.113.10:50000           (data, client-initiated)<\/code><\/pre>\n<p>Because both connections are outbound from the client, client-side firewalls and NAT are happy. The burden moves to the <strong>server side<\/strong>: its firewall must allow inbound connections on whatever port it hands out, and the address in the <code>227<\/code> reply must be one the client can actually reach. Those two requirements cause almost every remaining passive-mode problem.<\/p>\n<h2>The comparison at a glance<\/h2>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<th>Active mode<\/th>\n<th>Passive mode<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Data connection opened by<\/td>\n<td>Server (from port 20)<\/td>\n<td>Client<\/td>\n<\/tr>\n<tr>\n<td>Client firewall must allow<\/td>\n<td>Inbound on a high port<\/td>\n<td>Outbound only<\/td>\n<\/tr>\n<tr>\n<td>Server firewall must allow<\/td>\n<td>Inbound 21, outbound from 20<\/td>\n<td>Inbound 21 + passive port range<\/td>\n<\/tr>\n<tr>\n<td>Client behind NAT<\/td>\n<td>Usually breaks<\/td>\n<td>Works<\/td>\n<\/tr>\n<tr>\n<td>Server behind NAT<\/td>\n<td>Works<\/td>\n<td>Needs the public address configured<\/td>\n<\/tr>\n<tr>\n<td>Typical use today<\/td>\n<td>Legacy \/ internal networks<\/td>\n<td>Default almost everywhere<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div style=\"border:1px solid #c5d3f8;background:linear-gradient(135deg,#eef2fd 0%,#ffffff 72%);border-radius:14px;padding:1.5rem 1.65rem;margin:2rem 0;\">\n<div style=\"font-size:.7rem;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:#2d5be3;margin-bottom:.55rem;\">&#128295; BackendSide Tool<\/div>\n<h4 style=\"margin:0 0 .45rem;font-size:1.15rem;color:#1a1916;font-weight:700;\">BackendsideFTP &mdash; Active or Passive, Saved Per Site<\/h4>\n<p style=\"margin:0 0 1.05rem;color:#3d3c38;font-size:.92rem;line-height:1.65;\">The Saved Site Manager in <strong>BackendsideFTP<\/strong> remembers each server&rsquo;s hostname, port, username, protocol, default remote folder and <strong>Active\/Passive mode<\/strong>, so the one legacy box that needs active mode never forces it on the rest. Per-site settings override your global defaults, and you reconnect in one click straight into the right folder. Free on the Microsoft Store.<\/p>\n<p>  <a href=\"https:\/\/backendside.com\/backendsideftp.php\" style=\"display:inline-flex;align-items:center;gap:.4rem;background:#2d5be3;color:#ffffff;font-weight:600;font-size:.85rem;padding:.6rem 1.2rem;border-radius:6px;text-decoration:none;\">Explore BackendsideFTP &rarr;<\/a>\n<\/div>\n<h2>Fixing passive mode on the server<\/h2>\n<h3>1. Pin a passive port range<\/h3>\n<p>By default many servers pick any ephemeral port, which is impossible to firewall sensibly. Restrict it to a known range. For vsftpd:<\/p>\n<pre style=\"background:#1e1d1b;color:#eceae6;padding:1rem 1.15rem;border-radius:8px;overflow-x:auto;font-size:.85rem;line-height:1.5;\"><code># \/etc\/vsftpd.conf\npasv_enable=YES\npasv_min_port=50000\npasv_max_port=50100<\/code><\/pre>\n<p>ProFTPD uses <code>PassivePorts 50000 50100<\/code>; Pure-FTPd uses <code>-p 50000:50100<\/code>; IIS has a &ldquo;Data Channel Port Range&rdquo; under FTP Firewall Support. A hundred ports is plenty for most small servers &mdash; each concurrent transfer needs one.<\/p>\n<h3>2. Open that range in the firewall<\/h3>\n<pre style=\"background:#1e1d1b;color:#eceae6;padding:1rem 1.15rem;border-radius:8px;overflow-x:auto;font-size:.85rem;line-height:1.5;\"><code># Ubuntu \/ Debian with ufw\nsudo ufw allow 21\/tcp\nsudo ufw allow 50000:50100\/tcp\n\n# firewalld (RHEL, Fedora, Alma, Rocky)\nsudo firewall-cmd --permanent --add-port=21\/tcp\nsudo firewall-cmd --permanent --add-port=50000-50100\/tcp\nsudo firewall-cmd --reload\n\n# Windows Server (PowerShell)\nNew-NetFirewallRule -DisplayName \"FTP passive\" -Direction Inbound `\n  -Protocol TCP -LocalPort 50000-50100 -Action Allow<\/code><\/pre>\n<p>Remember cloud security groups too: on most cloud providers the instance firewall and the provider&rsquo;s network-level rules are separate, and both must allow the range.<\/p>\n<h3>3. Advertise the public address when the server is behind NAT<\/h3>\n<p>This is the sneakiest one. A server on a private address behind a router or cloud NAT will happily reply <code>227 Entering Passive Mode (10,0,0,5,...)<\/code>. The client tries to connect to <code>10.0.0.5<\/code>, which is not reachable, and the listing hangs. Tell the server its public face:<\/p>\n<pre style=\"background:#1e1d1b;color:#eceae6;padding:1rem 1.15rem;border-radius:8px;overflow-x:auto;font-size:.85rem;line-height:1.5;\"><code># vsftpd\npasv_address=203.0.113.10\n\n# ProFTPD\nMasqueradeAddress 203.0.113.10<\/code><\/pre>\n<p>Then forward port 21 and the whole passive range from the router to the server. Some clients work around a private address in a <code>227<\/code> reply by reusing the control-channel address instead, and <code>EPSV<\/code> sidesteps it by sending only a port &mdash; but fixing the server is the reliable answer.<\/p>\n<h2>Why FTPS makes this harder<\/h2>\n<p>Older firewalls and routers include an &ldquo;FTP helper&rdquo; (on Linux, the <code>nf_conntrack_ftp<\/code> module; on many routers, an &ldquo;FTP ALG&rdquo;) that reads the control channel, spots the <code>227<\/code> or <code>PORT<\/code> line and opens the matching port automatically. With FTPS the control channel is encrypted, so the helper is blind &mdash; which is the whole point of encryption. That means FTPS <em>always<\/em> needs the explicit passive range and public-address settings above. Occasionally the helper causes the opposite problem by mangling plain FTP traffic; if a router rewrites addresses wrongly, disabling its FTP ALG often fixes it.<\/p>\n<h2>A troubleshooting checklist<\/h2>\n<ol>\n<li><strong>Login works, listing hangs?<\/strong> It is the data channel. Switch to passive mode first.<\/li>\n<li><strong>Passive still hangs?<\/strong> Read the <code>227<\/code> reply in your client&rsquo;s log. A private address (10.x, 172.16&ndash;31.x, 192.168.x) means the server needs <code>pasv_address<\/code> or its equivalent.<\/li>\n<li><strong>Public address but still timing out?<\/strong> The passive range is blocked &mdash; check the server firewall, then the cloud security group, then any router port forwarding.<\/li>\n<li><strong>Plain FTP works but FTPS hangs?<\/strong> You were relying on an FTP helper. Configure the range explicitly.<\/li>\n<li><strong>Transfers stop after a long idle period?<\/strong> A firewall or NAT dropped the quiet control connection mid-transfer; keep-alives help.<\/li>\n<li><strong>Test from outside.<\/strong> Checking from the server itself proves nothing about NAT. Use a phone hotspot or another network.<\/li>\n<\/ol>\n<div style=\"border:1px solid #c5d3f8;background:linear-gradient(135deg,#eef2fd 0%,#ffffff 72%);border-radius:14px;padding:1.5rem 1.65rem;margin:2rem 0;\">\n<div style=\"font-size:.7rem;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:#2d5be3;margin-bottom:.55rem;\">&#128295; BackendSide Tool<\/div>\n<h4 style=\"margin:0 0 .45rem;font-size:1.15rem;color:#1a1916;font-weight:700;\">BackendsideFTP &mdash; Read the Conversation, Not Just the Error<\/h4>\n<p style=\"margin:0 0 1.05rem;color:#3d3c38;font-size:.92rem;line-height:1.65;\">Every session tab in <strong>BackendsideFTP<\/strong> has a live Log panel with the full command-and-reply transcript for FTP and FTPS &mdash; so you can see the <code>227<\/code> reply and the address it hands back, right where the hang starts. Passwords never appear in it. Keep-alive pings stop idle sessions being dropped by a server timeout, and a session that drops unexpectedly reconnects on its own and returns to the folder you were browsing.<\/p>\n<p>  <a href=\"https:\/\/backendside.com\/backendsideftp.php\" style=\"display:inline-flex;align-items:center;gap:.4rem;background:#2d5be3;color:#ffffff;font-weight:600;font-size:.85rem;padding:.6rem 1.2rem;border-radius:6px;text-decoration:none;\">Explore BackendsideFTP &rarr;<\/a>\n<\/div>\n<h2>The real fix: stop needing a data channel<\/h2>\n<p>Every problem in this article comes from FTP&rsquo;s two-connection design. <strong>SFTP<\/strong> has none of them: it runs entirely over a single SSH connection on port 22, with commands and file data multiplexed inside it. One inbound rule on the server, nothing to forward, no NAT rewriting, no passive range. If you have SSH access to the server, moving to SFTP removes this whole category of support tickets &mdash; and encrypts everything as a bonus. For a deeper look at the security side, see our overview of <a href=\"https:\/\/backendside.com\/blog\/2026\/06\/23\/ftp-ftps-and-sftp-in-2026-choosing-a-secure-file-transfer-client-for-the-ai-era\/\">FTP, FTPS and SFTP in 2026<\/a>.<\/p>\n<p>BackendsideFTP speaks all three, so you can keep the FTPS-only hosting account and the SFTP server side by side in separate tabs while you migrate.<\/p>\n<h2>Key takeaways<\/h2>\n<ul>\n<li>FTP uses a control channel for commands and opens a <strong>new data connection<\/strong> for every listing and file &mdash; that is why logins succeed while listings hang.<\/li>\n<li><strong>Active mode<\/strong> has the server connect back to the client; it breaks behind client firewalls and NAT.<\/li>\n<li><strong>Passive mode<\/strong> has the client connect out twice; it is the right default, but the server must allow its passive port range.<\/li>\n<li>Behind NAT, the server must <strong>advertise its public address<\/strong> in the <code>227<\/code> reply, or clients try to reach a private IP.<\/li>\n<li><strong>FTPS hides the control channel from firewall helpers<\/strong>, so pin and open the passive range explicitly.<\/li>\n<li><strong>SFTP avoids all of this<\/strong> with a single connection on port 22.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Logged in fine, then the directory listing hangs? That is almost always the FTP data channel meeting a firewall or NAT. Here is how active and passive mode really work, why each one breaks, and the exact server and firewall settings that fix it.<\/p>\n","protected":false},"author":1,"featured_media":417,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,8],"tags":[47,41,48,39,49,46,40],"class_list":["post-364","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-networking","category-tutorials","tag-active-mode","tag-backendsideftp","tag-firewall","tag-ftp","tag-nat","tag-passive-mode","tag-sftp"],"_links":{"self":[{"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/posts\/364","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/comments?post=364"}],"version-history":[{"count":1,"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/posts\/364\/revisions"}],"predecessor-version":[{"id":418,"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/posts\/364\/revisions\/418"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/media\/417"}],"wp:attachment":[{"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/media?parent=364"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/categories?post=364"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/backendside.com\/blog\/wp-json\/wp\/v2\/tags?post=364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}