How to fix cURL error 7 failed to connect to Port 443

How to fix cURL error 7 failed to connect to Port 443

If you have encountered a “cURL error 7 failed to connect to Port 443” you know how stressful it is to figure out a solution. It causes a website to have a poor security check score altering your site’s performance.

I once encountered a “cURL error 7 failed to connect to Port 443” on one of my websites and it took me months before figuring out the solution. I tried following most articles on the same subject to no avail.

The REST API request failed due to an error.
Error: [] cURL error 7:Failed to connect to yoursite.com port 443: Connection refused (http_request_failed)

Recently I found a way to fix the error and I will show you step-by-step how to fix it. First of all, it is important to understand the common causes of a “cURL error 7” to avoid a similar occurrence in the future.

Related: How to fix the ERR_TOO_MANY_REDIRECTS

Common causes of a “cURL error 7 failed to connect to Port 443”

PayPal script

If you are using PayPal on your website, then this is the first thing to look out for. On one of my sites, I was using a PayPal donation button on my homepage and it happened one day as I was editing my PHP footer script a cURL error occurred. I tried deleting my browser cache memory but the issues persisted.

I then disabled all plugins and even reinstall WordPress, but the error kept showing up. After removing the PayPal script and deactivating all plugins again, the issue seemed to have disappeared. However, when I tried editing my posts the “cURL error 7 failed to connect to Port 443” showed up again.

Facebook login script

When this happens it is because your server firewall has blocked the curl request. This can also block your IP address making it almost impossible to validate a theme once you have installed it. You will always see this error whenever the curl request is not on the standard port.

The Rest API is used by WordPress and other applications to communicate with your web hosting server. The WordPress block editor heavily relies on the Reset API to display and save your pages and posts. When the curl error occurs, you will also receive a warning while editing your posts signaling that the block editor might encounter an error when saving your work, and you risk losing your precious articles.

Related: How to redirect to a new domain using Rank Math: Bulk Redirection using rank math

How to fix cURL error 7 failed to connect to Port 443

  1. Try to upgrade your PHP version.
  2. Disable all your plugins and activate them one by one to see if the error will resolve.
  3. You can also change to the default WordPress theme and see if the issue will resolve.

How I fix the Curl error 7 on my website

In my case, I was running my site on a Vultr unmanaged VPS using a Plesk panel and I could not get help from their support team. I had to figure out a way. I encourage you to consider a managed VPS where all your issues can be resolved by the support team. I recommend Cloudways-managed VPS where you can deploy an instance on Vultr, Digital Ocean, or Linode.

Cloudways has great customer support ready to handle the most complicated issues you might encounter. They have a 1-click WordPress install hence you don’t have to touch any code. Transfer your website to Cloudways today and get a 30-days $100 free credit.

How to fix curl error 7 on Plesk

If you decide to use unmanaged VPS and install the Plesk panel, use this method to resolve the curl error 7.

  1. On the Plesk panel click the “adviser” button.
How to fix cURL error 7 failed to connect to Port 443
  1. On the “recommendations tab” scroll down to firewall (which is free) and click install.
How to fix cURL error 7 failed to connect to Port 443
  1. This will take you to a new page where you can finish installing the Plesk firewall.
  2. Look for Plesk extensions (the 14th option on the list) click on it and turn the Plesk firewall on (which is the 2nd option) and click continue.
How to fix cURL error 7 failed to connect to Port 443
How to fix cURL error 7 failed to connect to Port 443
  1. Wait for it to finish the installation, and once it is done you will see that it automatically turns all the default firewall rules on.
How to fix cURL error 7 failed to connect to Port 443
  1. This will automatically resolve the cURL error as port 443 rules will have been reset.

If the “curl error 7” occurs when your firewall is on, then disable it and clear your browser’s cache memory and enable the firewall again.

How to fix curl error 7 on CyberPanel

Since we know that the Reset API is caused by a curl request failure on the server firewall, we have to focus on our server’s firewall.

  1. On the Cyberpanel dashboard under security, click on firewall and enable it if it was not set by default on the installation of the panel.
How to fix cURL error 7 failed to connect to Port 443
  1. If the 443 port is not enabled, add it to the firewall records. Use the following, name-quic, Protocol:udp, IP address: 0.0.0. 0/0, port:443.
How to fix cURL error 7 failed to connect to Port 443

That is all you need to resolve the curl error 7 on the servers’ end.

Related: How to install Cyber panel using SSH

How to fix curl error 7 on a server using SSH

Here is a Bash script that you can run on your server through SSH to troubleshoot the “curl error 7: Failed to connect to port 443” error:

#!/bin/bash

# Check if curl is installed
if ! [ -x "$(command -v curl)" ]; then
  echo 'Error: curl is not installed.' >&2
  exit 1
fi

# Check if the destination server is reachable
echo "Checking if destination server is reachable..."
if curl -I --silent --max-time 10 example.com > /dev/null; then
  echo "Destination server is reachable."
else
  echo "Error: Destination server is not reachable." >&2
  exit 1
fi

# Check if port 443 is open on the destination server
echo "Checking if port 443 is open on the destination server..."
if curl -I --silent --max-time 10 --connect-to ::443:example.com https://example.com > /dev/null; then
  echo "Port 443 is open on the destination server."
else
  echo "Error: Port 443 is closed or blocked on the destination server." >&2
  exit 1
fi

# Check if there are any issues with SSL/TLS
echo "Checking for SSL/TLS issues..."
if curl -I --silent --max-time 10 --insecure https://example.com > /dev/null; then
  echo "Successfully retrieved data over SSL/TLS. It is likely that there are no issues with SSL/TLS."
else
  echo "Error: There may be issues with SSL/TLS. You may want to try using the --insecure flag to bypass SSL/TLS checks." >&2
  exit 1
fi

echo "No errors detected. It is likely that the issue is not with your server or curl installation."

This script will first check if ‘curl’ is installed on the server. It will then check if the destination server is reachable and if port 443 is open on the destination server. Finally, it will check for any issues with SSL/TLS by trying to retrieve data over SSL/TLS with the ‘–insecure flag’.

Related: How to add Nginx rewrite rules using SSH

Please note that this script is intended as a starting point for troubleshooting and may not necessarily solve the “curl error 7: Failed to connect to port 443” error in all cases. You may need to try additional troubleshooting steps depending on your specific situation.

Disclosure: We may earn commission for purchases that are made by visitors on this site at no additional cost on your end. All information is for educational purposes and is not intended for financial advice. Read our affiliate disclosure.

Share this:

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *