Warning: ftp_login() expects parameter 1 to be resource, boolean given?

Warning: ftp_login() expects parameter 1 to be resource, boolean given?

I’ve recently experienced the php issue “Warning: ftp_login() expects parameter 1 to be resource, boolean given”.

This PHP error is caused by using bad credentials in your FTP connnect file, if your hostname, username or password are not correct.

It also can happen if the server is not accepting your FTP connection.

To retrieve / display the error, add this code to your PHP file that usually can trigger the error: or die(“Unable to connect to server.”); after $conn_id = ftp_connect($ftp_server).

The server can also deny the connections if you make more than one and you make the connections in a very small interval (seconds).


To solve this issue, add sleep(60); before each connection that you make.
Of course that you can try to lower the 60 seconds value, check what might be the limit, 10 seconds or 15.

sleep(60); is for making your script to wait 60 seconds before moving to the next lines of code (the next ftp connection).

Warning: ftp_login() expects parameter 1 to be resource, boolean given? in conclusion

Check if your FTP connection that is established within PHP if it has the correct credentials.
If you have a script that is running many connections, add a sleep() between each connection.

In my case, I was using a multiple FTP connections because I had a script that was uploading a file on many websites at once.
After adding sleep(); between each connection, my problem got solved.

Add a comment: