Fixing Secure Connection Error in WordPress
When configuring a new VPS some time we come across an issue in WordPress updates and adding new plugins. The error comes is ” 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 /home/username/public_html/wp-admin/includes/update.php on line 122 ” . There are multiple ways to fix this unexpected secure connection error in WordPress. We can try this following solutions based on your situation.
It is mostly a hosting and server related issues
Some time if your shared hosting server is under DDoS attack, then it is likely that the connection to WordPress.org will timeout causing the secure connection error.
In that case, you can wait for a few minutes and try again. If the error persists, then you need to reach out to your web hosting company’s support team.
Cloud or VPS Server Connectivity Issue
If you are on a cloud or VPS hosting, then it is possible that your server is unable to connect to WordPress.org due to some DNS issues.
In that case, you can point your server directly to WordPress.org servers. You will need to connect to your server using SSH.
SSH is short for secure shell which is very useful and is an encrypted protocol that allows you to connect to your server using command line tools and help to manage the server.
We can access server via SSH using PuTTy in Windows PC whereas Mac / Linux users can use the terminal app to access SSH.
For this we need login credentials for the account with shell access to your hosting account.
In Mac/Linux terminal, you can connect to your server like this:
Here don’t forget to replace username with your own username and example.com with your own domain name.
Once you are connected to the server, you need to run the following command:
This will open hosts file in editor window, and now we need to add the following code at the bottom of the file:
Above IP is for api.wordpress.org, always check it before using, as there may be change in this IP some time. So better to just ping api.wordpress.org and check if it is resolving to this IP. Now save this file by pressing
Ctrl + X on your keyboard.
You’ll now be asked if you want to save your changes to the file, press “Y” and hit enter.
Next, you’ll be asked to give a name to the file, here just hit enter on your keyboard.
Now save the file You can now save your changes and exit the the editor.
Great you have fixed the error. Visit your website to see if this resolved the error.
WordPress relies on PHP primarily, so if you don’t have the right version installed – or even some necessary extensions in place – it might not work as intended. With this in mind, cURL is a PHP extension that enables you to transfer files via the command line. To be more specific, you need cURL for WordPress to be able to download plugins from the official repository or update themes. Using SSH, execute the following command:
If you don’t find these line in php.ini
, go ahead and add them, just as you did with the previous method. Now save the changes to php.ini
and restart your server. This will force the file to load again, Now check if the error is fixed. Firewall needs to be checked if it is blocking the ports which are used by web server software. By default, Apache
use either port numbers 80
– so those are the two ports should not be blocked by firewall.
Now check the error should be fixed. Great job done.