The error occurs when Passive is 1 – and occurs not if Passive is 0.
my $ftp = Net::FTP->new($server, Debug => 0, Passive => 0)
For more information:
In the active mode, the client starts listening on a random port for incoming data connections from the server (the client sends the FTP command
PORT to inform the server on which port it is listening). Nowadays, it is typical that the client is behind a firewall (e.g. built-in Windows firewall) or NAT router (e.g. ADSL modem), unable to accept incoming TCP connections.
For this reason the passive mode was introduced and is mostly used nowadays. It is a default for WinSCP too. Using the passive mode is preferable because most of the complex configuration is done only once on the server side, by experienced administrator, rather than individually on a client side, by (possibly) inexperienced users.