PROBLEMS WITH FTP -PASSIVEPORTRANG

TASA 40 Reputation points
2025-11-12T06:54:10.71+00:00

Hello!

I have a problem with the FTP protocol. I am transferring files to a domain via the command line. The company that rents the domain changed the operating system from CloudLinux 7 to Cloud Linux 9. And since then the transfer has not worked for me. It looks like this:

ftp.exe -s:start.txt

ftp> open test.com

Connected to test.com.

220----- Welcome to Pure-FTPd [privsep] [TLS] ----------

220-You are user number 1 of 50 allowed.

220-Local time is now 18:58. Server port: 21.

220-This is a private system - No anonymous login

220-IPv6 connections are also welcome on this server.

220 You will be disconnected after 15 minutes of inactivity.

504 Unknown command

User (test.com:(none)):

331 User ******@piapula.com OK. Password required

230-OK. Current restricted directory is /

230 28515 Kbytes used (5%) - authorized: 512000 Kb

ftp> binary

200 TYPE is now 8-bit binary

ftp> cd DIRECTORY

250 OK. Current directory is /DIRECTORY

ftp> path "TESTFILE1.TXT"

200 PORT command successful

425 Could not open data connection to port 50214: Connection refused

ftp> path "TESTFILE2.TXT"

200 PORT command successful

425 Could not open data connection to port 50215: Connection refused

ftp> bye

The support told me that these ports are not open and that I have to adjust the script. The ports that exist are 50000 to 50100.

My transfer script looks like this:

open test.com

******@test.com

Test555

binary

cd DIRECTORY

put "TESTFILE1.TXT"

put "TESTFILE2.TXT"

bye

Please where do I need to change that port range.

Developer technologies | Windows Forms
0 comments No comments
{count} votes

Answer accepted by question author
  1. Gade Harika (INFOSYS LIMITED) 2,020 Reputation points Microsoft External Staff
    2025-11-13T09:44:00.5266667+00:00

    Thanks for the update!

    The error occurs because:

    • Windows ftp.exe does not support passive mode.
    • Your hosting provider only allows passive mode with ports 50000–50100.

    Why WinSCP Command Failed winscp.com is not recognized because the WinSCP folder is not in your PATH. You can:

    1. Navigate to the WinSCP installation folder:Thanks for the update! The error occurs because:
      • Windows ftp.exe does not support passive mode.
      • Your hosting provider only allows passive mode with ports 50000–50100.
      Why WinSCP Command Failed winscp.com is not recognized because the WinSCP folder is not in your PATH. You can:
    2. Navigate to the WinSCP installation folder:
         cd "C:\Program Files (x86)\WinSCP\"
         winscp.com /script=C:\path\to\script.txt
      
      1. Or add the folder to your PATH.
        Correct Script
        open ftp://username:******@test.com/
        option transfer binary
        put "SCRIPTA.TXT" /DIRECTORY/
        put "SCRIPTA.TXT" /DIRECTORY/
        exit
      Curl Issue Your curl version does not support FTP. Download the latest curl from curl.se/windows and use:
         curl --ftp-pasv -u "username:password" -T TESTFILE1.TXT ftp://test.com/DIRECTORY/
      
      Passive mode ensures the server uses its allowed port range and avoids the 425 Could not open data connection error. If the issue has been resolved, Kindly mark the provided solution as "Accept Answer", so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

Answer accepted by question author
  1. Gade Harika (INFOSYS LIMITED) 2,020 Reputation points Microsoft External Staff
    2025-11-12T13:01:42.79+00:00

    Thanks for reaching out.

    The error occurs because the current FTP script uses active mode, which requires the server to connect back to the client on random ports (e.g., 50214, 50215). These ports are blocked by the hosting provider. Since they only allow passive mode with ports 50000–50100, you need to switch your FTP client to passive mode.

    Why Passive Mode Solves It

    In passive mode, the server opens a port in its allowed range (50000–50100) and the client connects to it. This avoids firewall/NAT issues and the ‘425 Could not open data connection’ error.

    Steps to Fix

    1. Enable Passive Mode in Your FTP Client.
    2. The built-in Windows ftp.exe does not support passive mode. Use a client that supports passive mode, such as WinSCP, curl, or lftp.

    Example using curl in Passive Mode

    Use the --ftp-pasv option with curl to enable passive mode:
    curl --ftp-pasv -u "username:password" -T TESTFILE1.TXT ftp://test.com/DIRECTORY/
    curl --ftp-pasv -u "username:password" -T TESTFILE2.TXT ftp://test.com/DIRECTORY/

    Example using WinSCP Script

    Create a script file (script.txt) with the following content: open ftp://username:
    ******@test.com/
    option transfer binary
    put TESTFILE1.TXT /DIRECTORY/
    put TESTFILE2.TXT /DIRECTORY/
    exit
    Run it using: winscp.com /script=script.txt

    Additional Notes

    Passive mode ensures the server uses its allowed port range and avoids the ‘425 Could not open data connection’ error. If you need automation, WinSCP scripting or PowerShell can be used for batch transfers.

    Let me know if the issue persists after following these steps. I’ll be happy to assist further if needed.

    If the issue has been resolved, Kindly mark the provided solution as "Accept Answer", so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.


3 additional answers

Sort by: Most helpful
  1. TASA 40 Reputation points
    2025-11-12T13:39:29.7133333+00:00

    Dear!

    Thanks for your answer. I installed winscp on my computer. I wrote scriptu.txt according to your instructions. Opened cmd and wrote the syntax

    winscp.com /script=script.txt.

    This is the message I get.

    'winscp.com' is not recognized as an internal or external command,

    operable program or batch file.

    The script looks like this:

    open test.com

    ******@test.com

    Test555

    option transfer binary

    put "SCRIPTA.TXT" /DIRECTORY/

    put "SCRIPTA.TXT" /DIRECTORY/

    exit

    C:>winscp.com /script=script.txt

    'winscp.com' is not recognized as an internal or external command,

    operable program or batch file.

    C:>

    Where can I run that command.

    0 comments No comments

  2. TASA 40 Reputation points
    2025-11-12T15:29:41.5533333+00:00

    Hello!

    I also tried the curl option.

    When I type curl --ftp-pasv -u "username:password" -T TESTFILE1.TXT ftp://test.com/DIRECTORY/ in the command line, I get the message

    "curl: option --ftp-pasv: is unknown" and abort the action.

    0 comments No comments

  3. TASA 40 Reputation points
    2025-11-18T16:19:38.25+00:00

    Hello!

    Sorry for not responding sooner. I was busy.

    I implemented your suggestions and the transfer works. I still need to transfer it to a batch file, to automate the transfer. You have helped me a lot, a lot and thank you very much. If I encounter a problem, can I contact you?

    Thanks again.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.