We got the message “Unexpected communication error with Stripe – Network error errno 2” suddenly on the website of one of my clients using Magento. The text entered as the error message was “If this problem persists, please let us know at email@example.com [ Network error errno 2] . This was an unusual error, as the error code was different from some of the error codes we were used to seeing.
Learn more about the issues and technology causing the errno 2 network error.
From our findings, we understood that the problem is not explicitly related to Magento 2, but to the CURL version. For example, many people have reported on GitHub and Stack Overflow how their Stripe suddenly stopped working. Or their email system could not work and displayed the Network error[errno 2] . A discussion on GitHub shows that the issue is still being investigated. If you are using a different technology than Magento, you can check this link to understand how to fix the problem on your site.
How to fix network error errno 2 on Magento 2 for Stripe?
If you encounter a network error[errno 2] on your website Magento 2 , which is preventing your band or payment method from working, you can do the following:
- Go to your Magento 2 installation folder
- Check the file “seller / Stripe / Stripe-php / lib / HttpClient / CurlClient.php”.
- Then modify:
protected $enablePersistentConnections = true;
protected $enablePersistentConnections = false;
- Finally, save and try to checkout.
If you follow the steps above, you will find that your order will work fine.
Other solutions to fix the problem
From the discussion on the internet, some people were able to solve the problem by using either of these methods:
- Update the version of their server,
- Downgrade their version of curl or
- Update of their website.
Conclusion and final remark
It is possible that the problem occurs on other modules of your website. From what I understand, setting the persistent connection / HTTP keep-alive to false will give you a temporary fix. As a member of the Stripe support team mentioned, the approach suggested above is a temporary fix. Internal investigations are still ongoing. I am making a comment here by GitHub . “Note, however, that this is only a workaround, not a proper fix, and is suboptimal, as it disables persistent connections (meaning that every request to Stripe’s API will create a new connection, resulting in additional latency) “.
Thanks for reading. Hope this article helps you save a few hours. If you need help with any of your Magento projects, you can Contact us .