How to Fix Secure Connection Error in WordPress
In the following guide, we will tell you what the meaning behind the Secure Connection Error in WordPress is and why it occurs. Then we’ll give you a few methods for how to fix the Secure Connection Error in WordPress.
WordPress is one of the most popular content management systems, used by millions of users around of the world. If you are a WordPress user, you may have come across some kind of WordPress-related error while working on your site. One of the WordPress errors that you may have encountered is the Unable to Establish Secure Connection error. Fortunately, repairing the Secure Connection Error in WordPress is a fairly easy task if you carefully follow the steps bellow.
The WordPress secure connection error generally happens when you attempt to install or update a plugin or theme from the official WordPress.org database. Even if you don’t do this manually, your WordPress always checks if there are new updates available for your existing plugins, themes, or WordPress core files. During this process, your server has to connect to WordPress.org in order to check for any available updates. If your server cannot reach the WordPress.org server and establish a secure connection, then the following error will appear in your browser:
An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration.
If you keep having issues, please try the support forums.
(WordPress could not establish a secure
connection to WordPress.org. Please contact your server administrator.)
/var/www/wordpress/wp-admin/includes/update.php on line 122
Because we know what causes this error and why it happens, we can move on and take a look at some of the possible solutions to fix it.
Server Related Issues
Depending on your hosting environment, there are few possible ways to approach solving this problem. If you are on a Shared Hosting server, it might be that the server is currently under heavy load or under a DDoS attack. This will most likely result in a timeout while trying to connect to the WordPress.org server, resulting in the secure connection errors. If this is the case, you could wait for a bit of time to pass before trying again, or you could try to contact your hosting company, so they can investigate the issue. This error can also happen as a result of a DNS-related issue. If you have a Virtual Private Server (VPS) and you have SSH access to the server, you can try to fix this by editing your server’s host files. To do this, first, you need to connect to your server via SSH. Once you are successfully connected, you can execute the following command:
This is going to open the /etc/hosts file with the nano text editor. Then you will need to copy and paste the following line to the end of the file:
After you save the file, go back to your WordPress admin and try to look for updates again to see if the Unable to establish secure connection error has been fixed.
cURL Extension for PHP
Because WordPress is made in PHP, it needs the correct version and extensions to be installed in order to function properly. In our case, in order for your WordPress site to be able to connect to WordPress.org and check for and download the required updates or plugins, you will have to make sure that the cURL PHP extension is installed and enabled. For example, to install the cURL extension for PHP 7.0 on a Ubuntu server, you can use the following command:
apt-get install php7.0-curl
On CentOS, you may do the same by running the command below:
yum install php7.0-curl
After you do this, make sure that you restart your web server (Apache or Nginx) with the following commands:
systemctl restart apache2
systemctl restart nginx
Check Your Firewall
If you have a Firewall service installed on your server, you will need to check that the ports used by your web server are not blocked by any firewall rules. The default web server ports used by Apache or Nginx are 80 or 8080 for HTTP and/or 433 for HTTPS. If you are using the UFW firewall, you can use the following commands to open these port numbers. For Apache:
ufw allow 'Apache Full'
ufw allow 'Nginx Full'
You should then check the status of your firewall and confirm that the changes are applied with the command below:
You may now go back to your WordPress site and try to run the update check again to see if the secure connection error has been fixed.