Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

If you're a developer and work on a Mac, you've most likely hit this error at some point in time. The dreaded "Safari Can't Open the Page" error which tends to occur when self-signed certificates are used and changed on servers in a development environment.

Unfortunately all Safari tells you is "Safari can't open the page https://XXXX because Safari can't establish a secure connection to the server XXXX". As far as error messages go, it's not very useful. Also, there are no options to continue to the page anyway.
priv_1.png


The JavaScript Console doesn't provide any extra detail either, but it does mention SSL at least...
priv_2.png


There are two easy ways to get past this error however.

1. Use Safari's "Private Window" to open the page you want.

This approach is ok for a quick one-off event, but doesn't provide a long-term solution. This is because Safari will not keep settings for any actions performed within the private window.
priv_3.png


When opening the site you want to visit in a private window, you will be presented with a warning saying "This Connection Is Not Private". Click the "Show Details" button.
priv_5.png


You will be warned that the certificate is not valid, but you are also given a chance to visit this website anyway. Click that. You'll be prompted for your password and then Safari will open the website.
priv_4.png




2. Clear the HSTS cache

A more permanent solution is to clear the HSTS cache. This is done by running the following commands via the Terminal app...
 Terminal
killall nsurlstoraged
rm -f ~/Library/Cookies/HSTS.plist
launchctl start /System/Library/LaunchAgents/com.apple.nsurlstoraged.plist


After running these, you will need to restart Safari. Then, when visiting your site, you will be prompted with the same warnings that are shown in a private window, except this time when you enter your password, Safari will save these settings.

-i


A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.