Dernière mise à jour: 07/12/2017
This article describes a problem with Wordpress 4.9.1+ where it is not possible to install custom plugins or themes through the Wordpress dashboard.
At first sight, it seems the Wordpress installation failed, or there is a problem with the hosting itself.
If you take a closer look, Wordpress uses cURL to connect to the api.wordpress.org server, behind the scenes.
Even if you try to establish the connection (through SSH) from the server, there seems to be no issue, the server can be reached.
If you execute a manual cURL call:
You can connect...
On the other hand, if you tend to use IPv6 to connect:
curl -6 api.wordpress.org
You might get an error. So, let's fix the IPv6 problem shall we? Not really... setting your server on IPv6 may not fix the problem.
But, it helps us in understanding the "why" of the error.
The problem seems to be related on hostname resolving, of some sort.
The only way to get around the problem is by adjusting a Wordpress core file. Sure it is NOT DONE, and by updating this file you break the updates in the future, but at least you can continue with your work!
By the time of this writing (07.12.2017) there was no fix yet for the connection problem, so for now this is the only "easy" solution.
Writing a custom action or plugin won't really help either since it is a core functionality within Wordpress.
Modify the wp-includes/Requests/Transport/cURL.php file and add the following line (at line 97):
curl_setopt($this->handle, CURLOPT_RESOLVE, array("api.wordpress.org:80:184.108.40.206", "api.wordpress.org:443:220.127.116.11", "downloads.wordpress.org:80:18.104.22.168", "downloads.wordpress.org:443:22.214.171.124"));
This is a temporary solution, but at least it helps you to continue installing plugins etc...