Before tackling this problem, it's important to understand why this error has occurred at the first place.
When you get to see the error ERR_CONNECTION_REFUSED appearing on Google Chrome, it's a sign that your browser is blocking the connection between your machine and the server to which the website belongs. There are many reasons why this error appears, but in this article, I am assuming you have tried all or most of the following:
- Tried visiting website in Incognito Mode
- Force refresh (cmd/ctrl + Shift + R)
- Delete cache files
- Delete all browser data including history, passwords, cached files, cookies etc
- Disable/Remove all extensions
- Reboot your Router
- Reboot your Computer
- Change DNS address to 184.108.40.206
- Change your IP address
If you tried all the above, and none of the browsers from your Mac seem to be able to visit that website, but you are able to do so from your phone and other devices from the same network, then the next solution will most likely help you.
- Click on your Desktop and navigate to Go > Go to Folder ... from the main menu bar on the top of your screen, or press command + Shift + 6 keys from your keyboard.
- type the following path /etc/hosts and press Go. This will take you inside the etc folder within the private directory and the hosts file should be highlighted.
- The Private directory contains configuration files which are reserved by your operating system. File like these include system logs (error windows showing up in your screen), memory swapping, configurations for command line tools etc. By any means, you should not rewrite any of these files, move or delete them. Although some of them are regenerated when you reboot your system, but there is always a possibility that you may ruin your machine. However, if you follow my steps strictly, none of the above will happen.
- From the etc folder, press the keys command + up arrow key to move up a folder.
- Now you should see 4 or so folders (directories) within the private folder. Right click on the etc folder and from the menu, choose Get Info.
- A window should appear. This displays some of core information (meta data) about that folder. From here, we need to change the permissions so we will be able to do any changes (write) on any files within that folder. To do that, go to the bottom of the window where it says Sharing & Permissions and click on the little locker on the bottom right. You may need to enter your password for this.
- Now on the everyone section, click on the Read only arrows pointing both up and down. A small dropdown should appear on the left. Choose Read & Write.
- Click on the yellow locker (on the bottom right of the window) to save the changes you just made. Then double click on the etc folder to open it again and scroll down until you find the hosts file. Once you find it, right click on it and from the drop down menu choose Get Info.
- Repeat the process from steps 6-7 to enable Read & Write privileges to the hosts file. Don't forget to lock the locker on the bottom right to save the changes.
- Right click again on the hosts file and open it with TextEdit. A new window should open.
- On the new window opened, you should be able to make changes. In my case, I was having trouble opening the techlunar.com website, and hence I will remove the line containing "techlunar.com". The hosts file works by manually converting domains into specified IP addresses without the need of the browser to look them up through in the DNS (Domain Name Server). As you may see below, when I type "techlunar.com" on my favourite browser, the browser thinks I typed 127.0.0.1 meaning that the browser doesn't look into the DNS to find the equivalent IP address of where the "techlunar.com" is located. The reason why techlunar.com was there was either I manually modified the file sometime in the past or it was automatically added there by a 3rd party software somehow.
- After that, save and close the window.
Now you may change the privileges again on both hosts file and etc directory back to Read only. Follow steps 6-7 but instead, Choosing Read Only instead of Read & Write.
- Visit the website again on your favourite browser. In case it doesn't work, then make sure to delete any cache files from your browser.
That's all! I hope I manage to resolve your issue after me spending a few days trying to figure out why I couldn't visit techlunar.com.
Please, let me know whether you found this article helpful and if you did, don't forget to share it so more people become aware of this.
Furthermore, we love feedback as much as producing these articles. If you have any feedback you would like to share, don't hesitate to leave it in the comment section below!