3 Ways to Fix the Unable to Establish Secure Connection Error in WordPress

Last Updated on October 2, 2022 by 5 Comments

3 Ways to Fix the Unable to Establish Secure Connection Error in WordPress
Blog / Tips & Tricks / 3 Ways to Fix the Unable to Establish Secure Connection Error in WordPress

WordPress errors are somewhat rare, but the platform is so popular that almost all of them are well-cataloged. For example, the WordPress secure connection error pops up rarely, but when it does, it can hinder you from installing new plugins and themes.

If you have full access to your server, fixing this error isn’t overly complicated. The only problem is, it can have more than one cause, so you may need to try a few things before you hit the jackpot. In this article, we’ll talk more about what the WordPress secure connection error is, and teach you multiple ways to fix it. Let’s get to it!

What the WordPress Secure Connection Error Is (And What Causes It)

The WordPress secure connection error usually occurs when you’re trying to install or update plugins and themes from WordPress.org. If you ever run into it, you’ll see a message much like this one:

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

Unlike other bugs such as the White Screen of Death, you’re given a clue as to what’s wrong. The bad news is the advice it gives you on how to solve the error is rather lackluster. There are several ways to tackle this particular error, but first, let’s talk about some of its potential causes:

  • Your website is under a heavy load. If you’re using shared hosting, for example, a lot of traffic can cause a strain on your server’s resources. That strain can cause your connection requests to WordPress.org to time out.
  • A misconfiguration in your server. In some cases, your website might try to connect to the wrong address instead of WordPress.org due to a misconfiguration.
  • A problem with your firewall.  A lot of modern web hosts implement a firewall system that blocks potential malicious connections. To do this, those firewalls often block entire ports as a precaution, and it might be they disabled the one your website needs.
  • Your website can’t run the necessary script to get the files it needs. When your server tries to download a file from a remote source, it runs a command line tool called cURL. We’ll talk more about how it works later, but suffice to say, if the tool isn’t there your site won’t be able to establish the connection it needs.

In the next section, we’ll teach you how to troubleshoot most of those issues. However, if the source of the error is an abundance of traffic, you may want to consider waiting it out, upgrading your plan, or contacting your host to see if they can increase your server’s resources temporarily.

3 Ways to Fix the WordPress Secure Connection Error

Before we go any further, you should know none of these fixes will work if you’re using a shared hosting plan. This is because you’re not given full access to your server’s configuration, unlike options such as a Virtual Private Server (VPS) or dedicated server. If you do use shared hosting, your best bet is to contact your web host’s support team right away so they can make the necessary adjustments.

In this section, we’re going to deal with fixes that require you to tinker with the way your server works – don’t worry, we’ll explain everything step-by-step!

1. Update Your Server’s hosts file

One of the most efficient ways to connect to your server and manipulate your files is through Secure Shell Access (SSH). If you’re a Windows user, you need to use a tool such as PuTTy to access your server. On the other hand, macOS or Linux users can use whichever command line tool they want to.

Let’s proceed with the assumption you’re using Windows. Once you install PuTTy and run the tool, choose SSH as your Connection Type. For hostname, you’ll need to use the address your web host provides you:

Connecting to your host via SSH.

On the next screen, you’ll need to log into your server via SSH using your server’s admin credentials. If you’re not sure what they are, try asking your provider’s support team:

Using your credentials to log into your server via SSH.

Once you’re logged in, you’ll have full access to your server, so we can finally get to work by running this command:

sudo nano /etc/hosts

This simply uses the nano editor to open the hosts file, which is basically a list used to associate particular IP addresses with websites:

An example of a WordPress hosts file.

The goal here is to ensure your hosts file is mapping WordPress.org to the correct IP address. To do that, we’re going to add an extra line to the file using nano:

66.155.40.202 api.wordpress.org

Once you save the changes to your hosts file, close it and return to your dashboard. Now try installing whichever plugin or theme gave you problems earlier. If the error persists, check out the other methods.

2. Check if the cURL Extension is Enabled for PHP

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:

sudo nano /etc/php.ini

If you’re a Windows user, look for the following line within the file:

;extension=php_curl.dll

Keep in mind the line looks slightly different for macOS and Linux users:

;extension=curl.so

If either of those lines is nowhere to be seen 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, at which point you should check if the error is gone.

3. Check if the Right Ports Are Open on Your Firewall

Whether your server uses a firewall out of the box depends mostly on the hosting service and plan you use. For example, if you’re using a VPS, you’ll probably need to set up and configure a firewall yourself.

If your server does use a firewall, you’ll want to make sure it doesn’t block the ports your web server software uses. By default, Apache and nginx use either port numbers 80 or 8080 – so those are the two you need to look out for.

Depending on your host, you may be able to configure your firewall directly from your control panel:

Configuring your internet's firewall.

In any case, your best bet is to check out your hosting provider’s documentation. Inside, you should find information about the way they implement firewalls and if they do so in the first place. If that’s the case, there should be instructions on how to unblock ports.

Conclusion

As far as WordPress bugs go, the secure connection error is mostly harmless. You can still upload themes and plugins manually via FTP if needed. Still, it makes sense to fix it as soon as possible. After all, it points towards a problem with your server’s configuration, which could impact you in order way if not sorted.

If you’re using a host that provides you with full access to your server, here are three ways to fix the Unable to establish secure connection error in WordPress:

  1. Update your server’s hosts file.
  2. Check if the cURL extension is enabled for PHP.
  3. Check if the right ports are open on your firewall.

Do you have any questions about how to fix the WordPress secure connection error? Let’s talk about them in the comments section below!

Article thumbnail image by Jiw Ingka / shutterstock.com.

Divi

Want To Build Better WordPress Websites? Start Here! 👇

Take the first step towards a better website.

Get Started
Divi
Premade Layouts

Check Out These Related Posts

Splice Video Editor: An Overview and Review

Splice Video Editor: An Overview and Review

Updated on March 10, 2023 in Tips & Tricks

Video is a valuable form of content for social media. Unfortunately, creating quality videos is usually a long process that involves moving mobile footage to a desktop app for editing. However, mobile editing is on the rise. Apps such as Splice Video Editor make it possible to efficiently create...

View Full Post
How to Use Font Awesome On Your WordPress Website

How to Use Font Awesome On Your WordPress Website

Updated on September 16, 2022 in Tips & Tricks

When given the choice between using a vector icon or a static image, it’s a good idea to go with the vector. They’re small and fast to load, and they can scale to any size without a loss of resolution. Font Awesome is a superb library of vector icons that you can use on your websites,...

View Full Post

5 Comments

  1. Actually there is a 5th scenario in which this error occurs… when you are developing on a localhost (your laptop say) and you don’t have an internet connection (you are flying on a plane and the laptop is in aeroplane mode). To remedy this error, I use the Airplane Mode plugin (https://github.com/norcross/airplane-mode), which allows one to run wordpress without an internet connection.

    • Hello Aurovrata.

      Thanks for pointing this additional scenario and solution out. It’s well worth keeping in mind.

  2. Finally! i just found a solution. Thank you John
    Good job!

    • Thanks. Happy to help.

  3. There seems a correction in conclusion first paragraph, last sentence:
    which could impact you in order way if not sorted.

    The word ‘order’ has to be ‘other’.

    Isn’t it?

Leave A Reply

Comments are reviewed and must adhere to our comments policy.

Get Started With Divi