I have a Windows 7 PC running FileZilla server. Then I have a PHP script on another server which connects to the FTP using ftp_connect.

This has been working absolutely fine for the past 4 months until yesterday, I started getting the following error:

Warning: ftp_login() expects parameter 1 to be resource, boolean given in blah.phpp on line 43

So I googled the error and found that this is the culprit:

425 Can't open data connection.

Here is the entire error log:

(000005)09/11/2011 09:40:47 - (not logged in) (myip)> Connected, sending welcome message...

(000005)09/11/2011 09:40:47 - (not logged in) (myip)> 220 Welcome to MY PC!

(000005)09/11/2011 09:40:47 - (not logged in) (myip)> USER vc

(000005)09/11/2011 09:40:47 - (not logged in) (myip)> 331 Password required for vc

(000005)09/11/2011 09:40:47 - (not logged in) (myip)> PASS *********

(000005)09/11/2011 09:40:47 - vc (myip)> 230 Logged on

(000005)09/11/2011 09:40:47 - vc (myip)> PWD

(000005)09/11/2011 09:40:47 - vc (myip)> 257 "/" is current directory.

(000005)09/11/2011 09:40:47 - vc (myip)> TYPE I

(000005)09/11/2011 09:40:47 - vc (myip)> 200 Type set to I

(000005)09/11/2011 09:40:47 - vc (myip)> PASV

(000005)09/11/2011 09:40:47 - vc (myip)> 227 Entering Passive Mode (192,168,1,5,217,112)

(000005)09/11/2011 09:40:47 - vc (myip)> MLSD

(000005)09/11/2011 09:40:58 - vc (myip)> 425 Can't open data connection.

(000005)09/11/2011 09:42:59 - vc (myip)> 421 Connection timed out.

(000005)09/11/2011 09:42:59 - vc (myip)> disconnected.

I've followed steps to reset my router but that didn't help. There has been absolutely change in the network settings between the time of it working and the first occurence of the problem. I also get the same error when connecting via an FTP client.

  • How have you configured the passive ports? The connection dies when the server tries to enter passive mode. I presume the server with php is outside the LAN and the ftp-server inside? Have you forwarded the passive ports on your router/firewall? Nov 9 '11 at 9:59
  • I have tried active mode as well, however yes the passive ports are forwarded.
    – rickyduck
    Nov 9 '11 at 10:00
  • What ports did you forward? How did you forward them? Can you use passive mode to connect to the FTP-server in the LAN? How did you configure the passive ports in the FTP-server? Nov 9 '11 at 10:03
  • I have forwarded the ports 20000-30000 and configured FileZilla server to use that for pasv connections. Connection in LAN works fine and just found out so does the connection to my IP from an outside computer. Just doesnt work within the PHP script (literally dying on ftp_connect("myip");
    – rickyduck
    Nov 9 '11 at 10:55
  • any possibility of your firewall causing this problem? some patch (KBxxxx) or a parameter change to close these ports?
    – A.Rashad
    Nov 10 '11 at 5:44

The problem was solved by changing from FileZilla Server to another FTP Server

  • 1
    It would be great if you could mark this as the answer (even though it doesn't explain what the problem really was)
    – pauska
    Dec 5 '11 at 10:15

The Filezilla server does not support simple FTP connection(It works with FTP(E)S) and since ftp_connect, curl, wget work with the ftp protocol you cannot connect to the FZ server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.