25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

How to fix cURL 56 recv failure connection reset by peer in CentOS?

by | Apr 22, 2020

Having trouble with cURL 56 recv failure connection reset by peer in the CentOS server?

The error occurs mainly due to failure in receiving network data.

At Bobcares, we often get requests to fix cURL errors as part of our Server Management Services.

Today, let’s get into the details on how our Support Engineers fix this error.

 

Why does cURL 56 recv failure connection reset by peer occurs?

cURL error 56 is a temporary error that happens due to different reasons like, idle server connection, firewall restrictions, whitespace in the URL, etc.

For instance, the error appears as follows.

cURL 56 recv failure connection reset by peer CentOS

Let’s detail how our Support Engineers fix this for our customers.

 

How we fix this error cURL error?

At Bobcares, we have more than a decade of expertise in managing servers, we see many customers facing errors. It happens mainly when fetching package updates, installing new software, etc.

Now, let’s see the major reasons and how our Support Engineers fix this error.

 

Idle server connection

Recently, one of the customers approached us with a cURL error. He was getting the following error while transferring the backup to the remote destination.

cURL error 56: TCP connection reset by peer

So we checked the backup log files and confirmed that the backups have been generated successfully.

On further checking, we found that the server was idle while transferring the backups to the remote destination. However, the backups were successfully exported to Google drive.

In addition, to avoid this situation, the tips we follow are:

  • We always upgrade the user’s OS to avoid TCP/IP issues.
  • Also, we use the recent versions of PHP and cURL.
  • Set the Maximum Transmission Unit (MTU) or the size of packets traveling over the network to the default value, 1500 bytes.
  • We ensure that the firewall is not blocking the user’s connection.

Bad repository

Often bad repository URL can also trigger curl 56 errors.

For instance, while trying to install PHP on CentOS7 server one of our customers received the error:

Loaded plugins: fastestmirror, langpacks
http://mirror.xxx.net/el7-x86_64/rpms/ ... repomd.xml: [Errno 14] curl#56 - "Recv failure: Connection reset by peer"
Trying other mirror.

Here, the customer was using an outdated repository and that caused the error. Therefore, we corrected the repo settings on the server and the package install went on fine.

Similarly, the repository may fail to load due to DNS resolution failures as well. In such scenarios, we make use of the /etc/hosts files to map the repo website to the correct IP address.

 

Whitespace in the URL

Another customer approached us with a similar problem.

On further investigation, we found whitespace in the URL. We then removed whitespace from the URL.

And in the PHP settings, we added the following.

curl_setopt($ch, CURLOPT_URL, trim($url));

In addition, If whitespace is a valid part of the URL, we use rawurlencode() function in PHP, to store the URL as encoded including whitespace.

 

[Need assistance in fixing cURL errors? – We can help you.]

 

Conclusion

In short, cURL 56 recv failure connection reset by peer in CentOS occurs when the server is idle due to running a long process or due to improper usage of URL. Today, we saw how our Support Engineers fixed the error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

6 Comments

  1. CJ

    I got this error because I set app up to require SSL certificate but i did not have https in the url. This blog helped me realize that right away. Thank you!

    Reply
    • Hiba Razak

      Hi,
      Glad to know that our article helps you solves the issue ? .

      Reply
  2. Vaibhav Wasnik

    Im still stuck in this error i have pull the image of jenkins application by creating dockerfile and when i went to
    run jenkins application on port so got this error

    curl localhost:9090

    connection reset by peer how could i solve this issue

    could anaybody guide me

    Reply
    • Hiba Razak

      Hi Vaibhav,
      Our experts can help you with the issue.we will be happy to talk to you through our live chat(click on the icon at right-bottom).

      Reply
  3. Suchita

    While connecting to the valid url from rhel8 vm getting below error how we can resolve this issue
    * Recv failure: Connection reset by peer
    * Closing connection 0
    curl: (56) Recv failure: Connection reset by peer

    Reply
    • Hiba Razak

      Hi Suchita,
      Our experts can help you with the issue.we will be happy to talk to you through our live chat(click on the icon at right-bottom).

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF