I'm using ftp_get to fetch some files for importing. I've been doing this for quite some time on several machines. I just migrated to a new machine and am now getting strange errors. I'm using PHP 5. I get things like:

Could not open data connection to port 35624: No route to host

the ftp connect seems to work, but when it gets to ftp_get is where this message occurs.

For a different connection I get:
Opening ASCII mode data connection for product.csv(122314510 bytes). in <pathtofile>

Which means what?

Any ideas what I'm missing?

Thanks

    I looks like the firewall on your machine is not configured properly to let FTP traffic pass.

      That was my first guess when I tried it, but then I just tried doing ftp from the command line and it was fine. Also, if it were a firewall issue I'd expect it to fail at the connection part, not when it fetches the file. Also why is it stating the error on port xxxxx? That port number changes each time I test the script. Seems strange.

      Thanks.

        That's how active FTP works. It allocated a "random" port on the client machine to connect to from the server. If your firewall is not configured to accept these incoming request, it will not work. I guess you are using passive active FTP from the commandline. In passive FTP no ports on the client are allocated. So you could also try to enable passive FTP in the PHP script.

          Ok, well then that would be the problem. Set ftp_pasv and voila, works now. I'm very surprised I have never run into this before...

          Thanks!

            Write a Reply...