cURL not working sometimes and gives empty result cURL not working sometimes and gives empty result curl curl

cURL not working sometimes and gives empty result


Possibly you call too many connections from your curl_init to one Ip Address, So the server blocks the connection and causes the on/off errors.


Not receiving any content back could be due to one or more out of many different reasons and you need to figure out which.

  1. Use curl_error($ch) in your code after the transfer has been performed to see if curl has told you about a problem.

  2. Investigate the response headers. A HTTP transfer can be successful and not return any error but might only respond with HTTP headers and no body at all. The HTTP headers may then contain clues as to why. Perhaps it is a redirect you should follow, perhaps it requires HTTP authentication or perhaps the server indicates a temporary server glitch.


Curl in PHP returns null on AWS EC2 instance

I had similar issue and I fixed it by making sure versions and settings in php.ini file which is in PHP5 and Apache2 folders were same. If its not then Apache2 tries to execute versions set inside the php.ini settings. Also make sure PHP5-libcurl is installed. Its important too.