Solution to Error Prompt CURL ERROR: Recv failure: Connection reset by peer when PHP executes Curl

  • 2021-07-04 21:38:48
  • OfStack

Recently, when using curl, I encountered an error prompt of CURL ERROR: Recv failure: Connection reset by peer. Now I share the solution with you, hoping to help you.

We often use curl to visit web site, and web site is mainly divided into http and https protocols at present. As we all know, https websites are all through ssl protocol + http protocol, which is the safest website protocol at present. When visiting such websites, we will go through ssl protocol to verify visitors' certificates and detect whether they are safe.

This is the same process for accessing such websites through curl, but corresponding parameters need to be added in curl to bypass the verification of ssl certificate before normal access can be made. For example, 1 reason for this error is that this parameter is not added (as shown below).


curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, false);

Related articles: