An FTP session logs in but its transfer gets 425 Can't open data connection; how do you work out which side failed to connect?
answer
- which mode was in use
- 425 answers the transfer command
- who was supposed to dial
- decode the announced endpoint
- 425 is not 426
basics
~20 sFind the mode first. After PORT or EPRT the server was dialling the client, so the client's announced endpoint was unreachable; after PASV or EPSV the client was dialling the port in the 227 or 229 reply, so that path failed.
solid answer
~50 s`425` arrives on the control connection in answer to the transfer command — `LIST`, `RETR`, `STOR` — not to `PORT` or `PASV`, which only set things up and get `200`, `227` or `229`. So read the lines just before it. If the client sent `PORT` or `EPRT`, the **server** was connecting, from port 20, to the endpoint the client named: check the server can reach that address and that inbound connections to that port are allowed on the client side. If the client sent `PASV` or `EPSV`, the **client** was connecting to the port in the `227`/`229` reply: check that address matches the server reached on port 21 and that the port is reachable. Switching mode is the quickest test — if passive works where active failed, the inbound path to the client is the fault. A connection that opens and then dies is `426`, a different fault.
go deeper
Recall that 425 means the data connection could not be opened while the control connection on port 21 is still working.
Explain why 425 answers the transfer command and not PORT or PASV, and name who was supposed to dial in each mode.
Diagnose from the transcript: mode first, then the announced or advertised endpoint, then a mode switch as the deciding test; keep 425 apart from 426 and from a refused PORT.
Treat recurring 425s as a design signal: if clients keep failing in active mode, standardise on passive and own the server-side port policy rather than fixing every client network.
## Where 425 comes from In FTP (RFC 959) the **control connection** to port 21 carries commands and replies, and every transfer or listing gets its own **data connection**. `425 Can't open data connection` is the reply the server sends on the control connection when that second connection could not be established. Three facts frame every diagnosis: - The control connection works — you are reading a reply on it — so login, credentials and port 21 are not the fault. - `425` answers a **transfer command** (`LIST`, `NLST`, `RETR`, `STOR`). It does not answer `PORT`, `EPRT`, `PASV` or `EPSV`; those only set things up and are answered `200`, `227` or `229`. - In RFC 959's reply sequences, `425` is one of the replies that can follow the preliminary `125` or `150 File status okay; about to open data connection`; either way, the data connection never came up. ## Step 1: find the mode in the transcript Read the lines just before the failing transfer command. | Setup command sent | Setup reply | Who was dialling | Endpoint that failed | |---|---|---|---| | `PORT h1,h2,h3,h4,p1,p2` | `200 Command okay` | the **server**, from its port 20 | the client's address and port in `PORT` | | `EPRT` with an address family, address and port | `200 Command okay` | the **server** | the client's address and port in `EPRT` | | `PASV` | `227 Entering Passive Mode (…)` | the **client** | the server's address and port in `227` | | `EPSV` | `229 Entering Extended Passive Mode`, port only | the **client** | the control connection's address, port in `229` | ## Step 2: active-mode failures Here the server tried to connect *into* the client: - **Decode the `PORT` address.** If it is not an address the server can reach — a private one, for example — the connection could never arrive; how address translation produces that is the subject of the material on FTP's NAT and firewall issues. - **Check inbound access on the client side.** A host firewall on the client, or a perimeter in front of it, that drops unsolicited inbound connections to the announced port produces exactly this `425`. - **Check the client was actually listening.** A client that announced a port and then failed to bind or accept on it looks identical from the server. ## Step 3: passive-mode failures Here the client tried to connect to the server: - **Decode the `227` address and compare** it with the address the control connection reached. If they differ, the server is advertising an endpoint the client may not be able to reach. - **Check the advertised port is reachable** from the client: a firewall in front of the server that admits only port 21 lets login through and stops every passive data connection. - **Read the client's own error.** In passive mode the client's connect attempt usually fails first with a local timeout or refusal; when the client still sends the transfer command, the server, which saw nothing arrive at its listening port, answers it with `425`. ## Telling 425 apart from its neighbours | What you see | What it means | |---|---| | `425 Can't open data connection` | the data connection never opened | | `426 Connection closed; transfer aborted` | it opened, then closed before the transfer completed | | a negative reply on the `PORT` line itself | the server refused the announced endpoint before trying it | | `522` with a list such as `(1)` | the server does not support the address family named in `EPRT` or `EPSV` | | no reply at all, then a client timeout | usually the same data-connection failure, before the server has given up | Mixing up `425` and `426` sends you to the wrong layer: the first is about reachability and who dials whom, the second about an established connection being cut. ## A diagnostic sequence 1. Confirm the control connection is healthy (login succeeded, other commands answered). 2. Identify the mode from the setup command and its reply. 3. Decode the endpoint — the `PORT`/`EPRT` argument or the `227`/`229` reply — and ask whether the dialling side can reach it. 4. **Switch mode** as the deciding test. If passive succeeds where active failed, the inbound path to the client is the fault; if both fail, look at the server's advertised data ports or at something blocking every data connection. 5. Only then look at middleboxes: firewalls that inspect FTP, NAT devices and encrypted control channels each have their own failure patterns, covered with FTP's NAT and firewall issues. ## Pitfalls - Blaming credentials or port 21 because the error appeared "during login" — it appeared at the first transfer. - Reading `425` as the reply to `PORT` and concluding the `PORT` syntax was wrong. - Assuming the server's port 20 must be reachable in passive mode — in passive mode the server listens on the port it announced, not on 20.
- Why does the FTP 425 reply appear after LIST rather than after PORT?`PORT` only records the address; RFC 959 answers it with `200 Command okay` and opens nothing. The server attempts the data connection when a transfer command such as `LIST` or `RETR` arrives, so that command's reply is where the failure is reported.
- How does an FTP 426 reply differ from 425?`425 Can't open data connection` means the data connection never came up. `426 Connection closed; transfer aborted` means it opened and then closed before the transfer finished — a reset, a timeout mid-file or an abort. The first points at reachability and who dials whom; the second at what happened to an established connection.
- Why is switching between active and passive mode a good first test for an FTP 425?It flips who dials. If passive succeeds where active failed, the server could not reach the client, so the inbound path to the client's announced endpoint is the fault. If both fail, look at the reachability of the server's advertised data ports or at something that blocks every data connection, whatever its direction.
- An FTP 425 means the login or the control connection failed
- The server answers PORT with 425 when the client is unreachable
- In passive mode a 425 means the server could not reach the client
- 425 and 426 are interchangeable ways of saying the transfer failed
- The server's port 20 must be reachable for passive-mode transfers