Safari cannot connect to localhost but can connect to 127.0.0.1
You probably installed something on your machine that acts as a web server and uses HTTP Strict Transport Security (HSTS) to make sure your browser knows it should always use TLS (HTTPS) when connecting. Then you connected to it by pointing your browser at localhost, and now your browser believes it should only use HTTPS when connecting to localhost.
Apparently Safari stores its list of HSTS websites in ~/Library/Cookies/HSTS.plist
, so you should be able to fix it by editing that plist file to remove the entry for localhost, or by deleting that plist altogether if you don't mind resetting the whole list of sites Safari has learned to strictly require TLS for.
Related videos on Youtube
The Kid From Yesterday
Just a teen trying to learn to program and wanting to change the computer industry!
Updated on September 18, 2022Comments
-
The Kid From Yesterday almost 2 years
For some reason, all of a sudden my Safari cannot connect to localhost because it cannot establish a secure connection. However, it is able to connect 127.0.0.1. Oddly enough Firefox is able to connect to localhost and 127.0.0.1. I believe it's some sort of certificate issue, but that's just a guess. What can I do so I can connect to localhost on Safari again?
Thanks
-
The Kid From Yesterday over 7 yearsI think this is the solution, but the only problem is that it keeps adding the localhost entry after I start Safari. Even if I delete the plist.
-
The Kid From Yesterday over 7 yearsDeleted this plist and restarted and this worked thank you so much!