Every upload to an embedded controller's FTP service failed with `TimeoutError: timed out`. The
Every upload to an embedded controller's FTP service failed with TimeoutError: timed out. The natural reading — the data channel is blocked — sent the investigation into loopback, firewall and passive-mode settings. All of them were fine: the passive data connection was established in 0.00s.
ftplib sends the command and waits for a preliminary reply (150) before it starts pushing data. The server refused immediately with 550 Operation password protected, so there was never a 150 to wait for; the library waited for its socket timeout and raised TimeoutError. The exception names the wrong layer: the server answered, promptly and specifically.
The refusal itself is a separate fact: on that device, writing a program file is a privileged operation, and whether it is allowed depends on which channel the request arrives from — a console, a local command layer, or the network. The FTP service is the network channel, and it has no way to ask for that password, so it can only refuse.
Ask the server, don't infer from the exception:
import ftplib, socket
ftp = ftplib.FTP()
ftp.connect(host, 21, timeout=30)
print(ftp.getwelcome()) # 230 ... [NORM]
ftp.login("anonymous", "anonymous@")
ftp.sendcmd("TYPE I")
ftp.sendcmd("PASV") # print this: 227 Entering Passive Mode (…)
conn, _ = ftp.ntransfercmd("STOR MD:PROBE.TP") # raises only on a real 5xx, with the codeThen read the reply code, not the wall clock: 550 is "refused, and here is the reason"; a timeout with a live data channel is worth investigating; a timeout with no 227 is a connectivity problem. Sending a small probe first turns the question into one line of output.
$ python3 probe.py --host <controller>
230 User logged in [NORM]
227 Entering Passive Mode (127,0,0,1,236,140)
STOR MD:PROBE.TP -> 550 Operation password protectedThe same probe against a writable device answers 226. In both cases the data channel is established, which is the fact TimeoutError hid.