Are you looking for a solution on how to fix WordPress could not establish a secure connection to WordPress.org error appearing on your WordPress dashboard?
Are you using WordPress and looking for a professional WordPress website builder? Look no further since Elementor can help you create beautiful pages.
The same above can also be seen on the logs;
tail /var/log/nginx/kifarunix-demo.error.log
...
2020/03/07 15:18:42 [error] 23961#23961: *3353 FastCGI sent in stderr: "PHP message: PHP Warning: An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums. (WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.) in /var/www/html/app.kifarunix-demo.com/wp-includes/update.php on line 380" while reading upstream, client: 192.168.56.1, server: app.kifarunix-demo.com, request: "POST /wp-admin/update.php?action=upload-plugin HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "app.kifarunix-demo.com", referrer: "https://app.kifarunix-demo.com/wp-admin/plugin-install.php"
...
So what causes this error?
WordPress comes bundled with mechanisms to contact WordPress REST API from where it can fetch the updates including WordPress core updates, plugins and themes updates.
When the updates are available, WordPress is able to display the notifications about respective updates.
In the event that WordPress is unable to connect to WordPress sites to fetch this information, you may encounter such an error.
Well, there are quite a number of suggested solutions online that explains how to fix this error including;
- Ensuring that curl (PHP extension) is installed
- Ensuring that no firewall blocks connection to
api.wordpress.org
ordownloads.wordpress.org
. - Ensuring that the
api.wordpress.org
ordownloads.wordpress.org
sites are resolvable by your DNS - Ensuring that your have the latest version of
openssl
command installed. - No SELinux related issues
- and many other solutions
However, there is one solution that stood out and helped me fixed this issue from WordPress support forum.
If you’re interested in reading 100s of more WordPress tips and tricks visit Collectiveray.com.
How to fix WordPress could not establish a secure connection to WordPress.org
Disclaimer: I can’t guarantee that this solution will work for you as the solution itself is not my own discovery. Just try your best. To add to this, if you aren’t tech-savvy, you should look into how to find a good WordPress developer that can solve the secure connection issue for you. It’s more than worth it, because you know it’ll get taken care of, risk-free.
The solution provided suggested that you have to edit the WordPress cURL.php
configuration and set an option for transfer to define a custom address on how WordPress can connect to api.wordpress.org
and downloads.wordpress.org
using both HTTP and HTTPS connections.
To implement the suggested solution, first create a backup of your wordpress cURL.php
configuration file.
cp /var/www/html/app.kifarunix-demo.com/wp-includes/Requests/Transport/cURL.php /var/www/html/app.kifarunix-demo.com/wp-includes/Requests/Transport/cURL.php.old
Next open the file for editing and add the following configurations at the end of the file.
vim cp /var/www/html/app.kifarunix-demo.com/wp-includes/Requests/Transport/cURL.php
...
add_action('http_api_curl', 'custom_curl_resolve', 10, 3 );
function custom_curl_resolve( $handle, $r, $url ) {
curl_setopt($handle, CURLOPT_RESOLVE, array(
"api.wordpress.org:80:XXX.XXX.XXX.XXX",
"api.wordpress.org:443:XXX.XXX.XXX.XXX",
"downloads.wordpress.org:80:XXX.XXX.XXX.XXX",
"downloads.wordpress.org:443:XXX.XXX.XXX.XXX")
);
}
Where XXX.XXX.XXX.XXX is the respective IP address of the provided domains.
Get the IP addresses of the api.wordpress.org and downloads.wordpress.org domains.
dig +short api.wordpress.org
198.143.164.251
dig +short downloads.wordpress.org
198.143.164.250
Update the configuration such that it looks like in below with the IP addresses updated.
add_action('http_api_curl', 'custom_curl_resolve', 10, 3 );
function custom_curl_resolve( $handle, $r, $url ) {
curl_setopt($handle, CURLOPT_RESOLVE, array(
"api.wordpress.org:80:198.143.164.251",
"api.wordpress.org:443:198.143.164.251",
"downloads.wordpress.org:80:198.143.164.250",
"downloads.wordpress.org:443:198.143.164.250")
);
}
Save and quit the configuration file.
Ensure that no firewall blocks connections to these sites.
curl https://api.wordpress.org -I
HTTP/1.1 302 Found
Server: nginx
Date: Sat, 07 Mar 2020 14:32:45 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Location: https://developer.wordpress.org/rest-api/
X-Frame-Options: SAMEORIGIN
curl http://api.wordpress.org -I
HTTP/1.1 302 Found
Server: nginx
Date: Sat, 07 Mar 2020 14:33:59 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Location: https://developer.wordpress.org/rest-api/
X-Frame-Options: SAMEORIGIN
curl http://downloads.wordpress.org -I
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Sat, 07 Mar 2020 14:34:39 GMT
Content-Type: text/html
Content-Length: 162
Connection: keep-alive
Location: https://downloads.wordpress.org/
curl https://downloads.wordpress.org -I
HTTP/1.1 302 Moved Temporarily
Server: nginx
Date: Sat, 07 Mar 2020 14:36:18 GMT
Content-Type: text/html
Content-Length: 138
Connection: keep-alive
Location: https://wordpress.org/download/
X-Frame-Options: SAMEORIGIN
X-nc: HIT ord 6
Next, restart your web server.
Ensure that no errors before restarting the web server.
nginx -t
httpd -t
apachectl configtest
The restart;
systemctl restart nginx
systemctl restart httpd
And phew, the error disappears on your WordPress dashboard. That is just it on how to WordPress could not establish a secure connection to WordPress.org
We hope this helped someone too.
Read more on the reference link below;
Error: WordPress could not establish a secure connection to WordPress.org
Related tutorials
Install WordPress with Nginx and MySQL 8 on CentOS 8
Install WordPress 5 with Nginx on Debian 10 Buster
Install WordPress 5 with Nginx on Fedora 30/Fedora 29
Install WordPress 5.x with Apache on Fedora 29/Fedora 28
How to Install and Use WPScan WordPress Vulnerability Scanner Ubuntu 18.04
Brilliant. Solved 99% of my problem.
The only thing left in SiteHealth on WordPress now is this one…
“Your server is blocking external requests to exactmetrics.com, please check your firewall settings or contact your host for more details. Error message: cURL error 28: Resolving timed out after 2072 milliseconds”
When in fact it’s not being blocked at all. ping, dig, telnet etc all reach exactmetrics.com fine.
But thanks for the fix above. Brilliant.
Thank you for the feedback Roberts, if you find a solution to the above, please be sure to post, 🙂
this solved like a must.
thank you a lot!
Thank you!! Finally a solutions that works!