PHP curl Connection timed out error PHP curl Connection timed out error curl curl

PHP curl Connection timed out error


Refering to the documentation of curl_getinfo(), connect_time is the time in second it took to establish last connection and total_time is the time in second for the last transaction.

You can redefine the timeouts using curl_setopt(). In example, curl_setopt($cHandler, CURLOPT_CONNECTTIMEOUT, 42); to set 42 seconds of connection timeout or curl_setopt($cHandler, CURLOPT_CONNECTTIMEOUT, 0); for no connection timeout. The same way, curl_setopt($cHandler, CURLOPT_TIMEOUT, 42); will define 42 seconds of execution timeout.


After struggling around 1 week and trying all suggested options finally I found that it was neither a connection issue nor API api-domain.com issue. Little strange for me but true that it's my SERVER scaling issue from which I am calling the API, I have increased the configuration (RAM and CPU) and found that the issue has been fixed.

Hope my experience with this issue help someone and save their time to troubleshoot.

Thanks, everyone for commenting and suggesting the solutions.