I use Vagrant as my environment for most of my development. The other day I was working on one of my installs when I received the following WordPress error throughout most of my admin:

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.)
After a ton of time sifting through forums and speaking to other developers, I finally ran down the source of my problem (thanks Ryan Sechrest), my DNS server was timing out while trying to connect to WordPress.org

The simplest fix for this is to add the following to your server's host file:

66.155.40.202 api.wordpress.org

This essentially provides a more direct connection to WordPress.org, which avoids any timeout issues.

If you don't know how to edit Vagrant's hosts file manually (I didn't the first time I did this), follow these steps:

  1. Just open up the console and navigate to your Vagrant file.
  2. Ssh into Vagrant using vagrant ssh
  3. Navigate to the etc directory cd ../../etc
  4. Open the hosts file using Nano sudo nano hosts
  5. Add 66.155.40.202 api.wordpress.org to the file and save.

Voilà! All your WordPress installs should now connect to WordPress.org quickly and without any errors.

Hope this helps someone else!

You can check out Ryan's original post about the same issue here.