"php_connect_nonb() failed: Operation now in progress (115)" happens intermittently "php_connect_nonb() failed: Operation now in progress (115)" happens intermittently linux linux

"php_connect_nonb() failed: Operation now in progress (115)" happens intermittently


ftp_set_option($ftpconn, FTP_USEPASVADDRESS, false);

This line of code before setting passivity of the connection ftp_pasv($ftpconn, true);

Solved my problem


FTP(S) uses random ports to set up data connections; an intermittent success rate indicates that not all ports are allowed by a firewall on the client and/or server machines. The port range for incoming (PASV) data connections can be set in the FTP server.

This page has a nice summary:

The easy way is to simply allow FTP servers and clients unlimited access through your firewall, but if you like to limit their access to "known" ports, you have to understand the 4 different scenarios.

1) The FTP server should be allowed to accept TCP connections to port 21, and to make TCP connections from port 20 to any (remote ephemeral) port.

2) The FTP server should be allowed to accept TCP connections to port 21, AND to accept TCP connections to any ephemeral port as well!

3) The FTP client should be allowed to make TCP connections to port 21, and to accept TCP connections from port 20 to any ephemeral port.

4) The FTP client should be allowed to make TCP connections to port 21, and to make TCP connections to any other (remote ephemeral) port as well!


So, I'm writing this answer after doing some investigation on my FTP server and reading the link you provided elitehosts.com.

I'm using FileZilla FTP server, and there is a specific setting that I had to enter to make it work. Going into the server settings, there is an area titled "Passive mode settings". In that dialog, there is an area titled "IPv4 specific", and within that area there is a setting labeled "External Server IP Address for passive mode transfers:". It's a radio button selection set, and it was on "Default", but since the FTP server is NAT'ed, I changed that radio selection from "Default" to "Use the following IP:" and entered in the external-facing IP address of my gateway provided by my ISP.

After I set this up, it worked! Not terribly sure if your FTP server is NAT'ed, but I thought I would provide the answer on this thread because it seems related.