WordPress could not establish a secure connection to WordPress.org
I’m using Vagrant to work on a WordPress site and noticed the following error throughout several admin pages that attempt to connect to WordPress.org:
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.)
Upon further investigation, since I knew there wasn’t an issue with WordPress.org, the response from WordPress’ wp_remote_post
call contained:
name lookup timed out
In my case, this was because the DNS server was unable to return a response in time (or at all).
A simple fix is to add api.wordpress.org
to your server’s host file.
If you use Puppet, you can do this via:
host { "api.wordpress.org":
ip => "66.155.40.202",
}
Or, if you just want to edit the host file manually (/etc/hosts
), you can add the following:
66.155.40.202 api.wordpress.org
Hope this helps someone else!
Featured image by Kaley Dykstra.
Comments (25)
Previously posted in WordPress and transferred to Ghost.
elihu
September 18, 2014 at 8:45 pm
You sir, are a scholar and gentleman. Thank you for the quickfix!
chinaski
October 5, 2014 at 9:24 pm
Yep, helped me too. Thanks for the post.
Josh G
October 7, 2014 at 1:32 am
Alas, while I’m in the exact same situation as you, adding it to the /etc/hosts
file doesn’t appear to fix it. I’ve tried everything at this point.
Ryan Sechrest
October 7, 2014 at 9:04 am
Temporarilyprint_r
the result ofwp_remote_post
and then try to generate the notice again by going to one of the admin pages. What is it printing out?
Till
October 28, 2014 at 8:20 pm
I had to increase the request timeout for api.wordpress.org
requests: https://gist.github.com/tillkruess/b2cb59f601d7144e3497
Ryan Sechrest
October 29, 2014 at 12:32 am
Good tip! Thanks for sharing it!
Copy of the Gist, in case it disappears:
<?php
// increase `timeout` for `api.wordpress.org` requests
add_filter( 'http_request_args', function( $request, $url ) {
if ( strpos( $url, '://api.wordpress.org/' ) !== false ) {
$request[ 'timeout' ] = 15;
}
return $request;
}, 10, 2 );
Mahfuzul Hasan
January 7, 2015 at 1:07 am
Awesome trick, Thanks for sharing. @Till and @Ryan
Mark Barnes
November 23, 2017 at 4:46 pm
Thank you for this. It’s still useful (and necessary!) three years on!
Volodymyr
November 3, 2014 at 8:12 am
Solved my “WordPress could not establish a secure connection to WordPress.org” error. Thanks a lot!
Jeris
December 22, 2014 at 10:23 am
yupp.. me too, thx
Erspek
April 6, 2015 at 3:08 am
Thank you.
Igor Brites
April 30, 2015 at 12:28 pm
Finally an answer! Thank you mister!
yuwuyan
May 5, 2015 at 9:01 am
Thanks a lot!
Tim Bunch
May 7, 2015 at 8:44 am
Thank you so much! My vagrant box has been spitting this message out randomly lately, until it was persistent this morning. This does appear to have resolved the issue.
Jacob
September 3, 2015 at 11:43 am
It took me forever to find this post! Thanks for sharing, it solved all my issues (which I had been dealing with for almost a week). You’re awesome!!!
ugo
December 7, 2015 at 6:42 pm
Awesome….thanks…problem solved
Gaia
December 13, 2015 at 11:22 am
Awesome…Awesome…Awesome…
thanks!!!
Edward
February 16, 2016 at 6:57 am
This solution helped me.
http://robert.penz.name/902/slow-dns-resolving-with-linux-systems-against-windows-dns-server/
It’s something wrong with DNS resolver.
Ryan Sechrest
February 16, 2016 at 9:05 am
Hi Edward, thanks for sharing this. Robert’s solution suggests addingoptions single-request-reopen
to/etc/resolv.conf
.
Daniel
November 14, 2016 at 1:22 pm
Thank you
I thought it was something related to SSL or Curl in Php.
I added this line (66.155.40.202 api.wordpress.org
) to/etc/hosts
on a Ubuntu 16.04 server and all worked.
Rashed Mahmud
March 1, 2017 at 4:28 am
After 4-5 hours finally got the solution. Thanks a lot
Shuvasis Datta
December 13, 2017 at 2:01 pm
This is great! It works in my case