How to Fix ERR_CONNECTION_REFUSED

how to fix err_connection_refused error

In this tutorial, we will show you how to fix the ERR_CONNECTION_REFUSED error that can happen both when accessing other websites as well as when trying to access your own website. This error shows up when trying to access a webpage and your connection to it gets refused by the server. However, this error can sometimes occur even though the server is not refusing your connection.

How to Fix ERR_CONNECTION_REFUSED On your Own Web Server or VPS

If this error occurs only when accessing your own webpage hosted on a Linux VPS, then the web server or the firewall on your server is refusing the connections initiated by your browser. You will need to check whether ports 80 or 443 are open on your VPS. You can do this in different ways depending on which firewall software you are using.

Using firewall-cmd we can easily check which ports are currently open by using this command:

firewall-cmd --list-ports

This is what the output should be:

80/tcp
443/tcp

Port 80 needs to be open for regular HTTP connections, while port 443 is for secure HTTP connections (HTTPS). If it isn’t open, then you can use the following commands to add them:

firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=443/tcp

Once you do that, you can reload Firewalld to apply the changes:

firewall-cmd --reload
success

If you are using iptables as your firewall of choice, then the commands are slightly different. You can check which ports are open by using the following command:

iptables -L -n | grep 80
iptables -L -n | grep 443

If you see these ports in the output of the command together with the ACCEPT term, then you do not need to change anything as your server is already allowing connections on that port. Otherwise, if the rules are set to DROP connections from these ports, you can change that with these two commands:

iptables -I INPUT 1 -p tcp -m multiport --dports 80,443 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 1  -p tcp -m multiport --dports 80,443 -m conntrack --ctstate ESTABLISHED -j ACCEPT

If necessary, run these as a superuser (by using sudo) in order to execute them. Then, once done, you can save your iptables configuration with the following command:

iptables-save > /etc/iptables.backup

Now, make sure that your web server is running. The command for this will depend on which Linux distribution you are running, as well as depending on which webserver software you are using.

RHEL-based Distributions (Such as AlmaLinux):

systemctl status httpd.service
systemctl status nginx.service

Debian-based Distributions (Such as Ubuntu):

sudo systemctl status apache2.service
sudo systemctl status nginx.service

If your server is stopped, start it by replacing the word ‘status’ with ‘start’ in the command corresponding with the webserver you are using.
Now, try to open your webpage again and see if the issue is resolved. Now that the ports are open and the webserver is running using those ports, you should be able to access your webpage without any issues.

Or, if you’re having trouble figuring it out, you can just sign up for our Managed VPS Hosting services and we’ll troubleshoot the issue for you once your sites are migrated over. We’re sure we can fix the connection refused error for you.

How to Fix ERR_CONNECTION_REFUSED On Your Computer

If you’re seeing this issue on just one website, then it’s likely that their website is down temporarily. You can try again in a few minutes or maybe even the next day. Sometimes the website owner won’t notice that there’s an issue, so it may take some time for them to fix it.

If this error occurs across several websites, then the issue lies within your browser or your machine. An easy way to check is by trying to access the same websites using a different device, such as your laptop or smartphone. If the error only occurs on your computer and does not affect other devices, then there are a couple of things you can try to fix this.

Wait a few minutes and try again

With this error, it’s possible that the server had too many connections and their web server crashed, which closed the port. Waiting a few minutes to try again can sometimes fix the issue.

Clearing your caches

While this might not seem like a very helpful thing to do, your browser can save error responses mistakenly. You can clear the cache in Google Chrome by following these steps:

  1. Click on the More menu in the top right (it’s an icon with three vertical dots).
  2. Click More tools > Clear browsing data.
  3. At the top, make sure to set the time range to All time.
  4. Only check the checkbox labelled “Cached images and files”.
  5. Click Clear data.

Once done, try and access the webpage again.

If this doesn’t help, then you can try deleting your cookies and website data.

Remove any Proxies

A proxy can also cause the ERR_CONNECTION_REFUSED error. If you enter “chrome://settings/” into your address bar in Chrome then search for proxy, you can scroll down and access your proxy settings. Make sure that your machine does not have a proxy enabled.

Disabling your firewall

It’s possible that your firewall is refusing your connection to their server. It’s worth trying to disable your firewall and then trying again. Then see if the firewall is the cause of the issue. Note that your router might also have a firewall enabled.

If you do any of these (or even a combination of several of them) make sure that you reboot your machine completely to ensure that all settings are saved, and that everything is reset. Once you have rebooted your machine, try and access the websites again. You should now be able to access these webpages with no issues.

That’s all we have for you – this should almost certainly fix your ERR_CONNECTION_REFUSED error. If you like this post on how to fix ERR_CONNECTION_REFUSED error, please share it with your friends through social networks. Alternatively, simply leave a comment. Thanks.

Leave a Comment