It happened to me to get the nasty “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.” message trying to install a new theme or plugin.
WordPress version: 4.7.
Solution: check the resolv.conf file. For some strange boot hiccup, my resolv.conf file was empty.
The problem appear when wordpress has no way of resolving names.
Solution: check /etc/resolv.conf file for a “nameserver x.x.x.x” line.
If you have no idea what am I talking about, just insert there “nameserver 126.96.36.199” without quotes.
Have a nice day 🙂