In this tutorial, we will explain the meaning of Secure Connection Error in WordPress and why it happens and then explain some of the methods on how to fix 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 many WordPress errors that you may encounter is the Unable to establish secure connection error. Repairing the Secure Connection Error in WordPress is fairly easy task if you carefully follow the steps bellow.
Table of Contents
The WordPress secure connection error usually happens when you try 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 needs 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 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 /var/www/wordpress/wp-admin/includes/update.php on line 122
Now when we know what this error means and when it happens, let’s move on and take a look at the some of the possible solutions to fix this problem.
2. Server Related Issues
Depending on your hosting environment, there are few possible ways how to approach on 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 a case you can wait for some time to pass before trying again, or you can try to contact your hosting company so they can investigate the issue. This error can also happen as a result of some DNS related issue. f you have Virtual Private Server (VPS) and you have an 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 will open the /etc/hosts file with the nano text editor. Place the following code at the end the file :
Once you save the file, return to your WordPress admin and try to check for updates again and see if the Unable to establish secure connection error has been fixed.
3. cURL Extension for PHP
Since WordPress is written in PHP, it requires 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 and download the required updates or plugins, you will need to make sure that the cURL PHP extension is installed and enabled. For example, to install the cURL extension for PHP 7.0 on Ubuntu server you can use the following command:
apt-get install php7.0-curl
On CentOS you can do it by executing:
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
4. 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 can then check the status of your firewall and verify that the changes are applied with the following command:
You can 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.