[Python] Connection Refused to FTP server in Airflow

Discussão em 'Python' iniciado por Stack, Maio 27, 2025.

  1. Stack

    Stack Membro Participativo

    I am attempting to transfer files from an FTP server to a local directory using airflow. I verified that my FTP server is working, using active mode I was able to connect to it on WinSCP on the computer with the Airflow instance, however, when I try retrieving files with the FTP Hook in python, after setting passive to false in the extra fields, I receive a connection refused error. Additionally, I have tested this script while running an FTP server on the same computer as my airflow instance and the file transfer works. This is my log file:

    {"timestamp":"2025-05-27T17:43:28.944478","level":"info","event":"Connection Retrieved 'testftp'","logger":"airflow.hooks.base"}
    {"timestamp":"2025-05-27T17:43:28.944625","level":"info","event":"Connecting via FTP to 169.254.252.37:21","logger":"airflow.providers.ftp.hooks.ftp"}
    {"timestamp":"2025-05-27T17:43:29.043478","level":"info","event":"Retrieving file from FTP: S004 2025-05-27 09-49-45 LB.txt","logger":"airflow.task.hooks.airflow.providers.ftp.hooks.ftp.FTPHook"}
    {"timestamp":"2025-05-27T17:43:50.122690Z","level":"info","event":"Unexpected error: [Errno 111] Connection refused","chan":"stdout","logger":"task"}

    Continue reading...

Compartilhe esta Página