Curl error troubleshooting

Source: Internet
Author: User

Curl error troubleshooting
Php curl Common Errors: SSL errors, bool (false)

Symptom: An error occurred while calling https in php curl.

Troubleshooting method: Use curl in the command line to call it.

Cause: the SSL certificate cannot be verified in the server room.

Solution: Skip the SSL certificate check.

Curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, false );


Symptom: php curl calls curl_exec and returns bool (false). The command line curl call is normal.


Var_dump (curl_error ($ ch ));

Check the returned values of the initialization and execution of the cURL function.curl_error()And setcurl_errno()In the event of a fault, further information is returned:

try {    $ch = curl_init();    if (FALSE === $ch)        throw new Exception('failed to initialize');    curl_setopt($ch, CURLOPT_URL, '');    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    curl_setopt(/* ... */);    $content = curl_exec($ch);    if (FALSE === $content)        throw new Exception(curl_error($ch), curl_errno($ch));    // ...process $content now} catch(Exception $e) {    trigger_error(sprintf(        'Curl failed with error #%d: %s',        $e->getCode(), $e->getMessage()),        E_USER_ERROR);}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.