Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Safari forcing HTTPS for some HTTP only sites

I have a strange issue with Safari (7.0.1 on Mavericks 10.9.1). It is similar to a few other issues that folk have posted about here but I am opening a separate post because some of the details are different. Please read to the end before suggesting I try disabling extensions, clear cache etc.


This issue is affecting only one user on one Mac (we have several users and several Macs).


We host our own web-site using OS X Server (Mavericks / Server 3.0). Soem areas of the site support both HTTP and HTTPS access. For example:


Live (public) site


http://www.ourdomain.com (on port 80)

https://www.ourdomain.com (on port 443)


and


Test (internal) site

http://www.ourdomain.com:81

https://www.ourdomain.com:444


and


Intranet (internal)


http://www.ourdomain.com:8080


Most areas of the site do not require HTTPS protection and in particular for the Test site both the htp and the https versions have explicit ports. For the Intranet site there is no HTTPS version. For the live and test sites, a certain sub-set of the site requires user authentication and I have redirects setup to redirect access to just those areas via the HTTPS URL which also enforces user authentication.


This setup all works fine, except for this one user on this one machine and only when they use Safari (Chrome and FireFox are fine)...


They have Safari bookmarks saved for the HTTP URLs and after a while:


1. These bookmarks start referring to tthe HTTPS URLs. The actual bookmarks get changed and the http gets changed to https! In the case of the Test and Intranet sites these URLs are not even valid. So, the bookmarks no longer work. If we edit the bookmarks and change them back to http they immediately revert back to https!


2. If one types the HTTP URL directly into the address bar then Safari ignores the HTTP and instead tries to go to the HTTPS version of the URL.


Basically, there is no way to get Safari to access the HTTP versions of any of these URLs with the resuklt that the Test and Intranet sites are unusable.


This user only has the same extensions as other users have and they all work okay. We have tried disabling extensions but it does not resolve the issue. Doing a full reset of Safari will resolve the issue temporarily but this deletes a lot of stuff, such as History, that the user does not want deleted. And the issue always recurs after a while anyway.


Does anyone have any idea what is causing this behaviour and how to prevent it? It is driving me and the affected user mad!

iMac, OS X Mavericks (10.9)

Posted on Feb 9, 2014 6:09 AM

Reply
Question marked as Best reply

Posted on Feb 9, 2017 8:04 PM

I realize this is an old thread, but I hope this helps someone in the future...


This problem infuriated me for a long time. As you suggest, Safari will cache HTTP Strict-Transport-Security requests from websites and automatically switch to https in the future. This creates a lot of problems when you are running multiple different servers on `localhost`, some of which request it, and others that don't. In my case, it caused connections to my Jupyter notebooks to fail after I had tunneled connections to other sites through ssh.


There are old posts elsewhere on the web that suggest quitting Safari, deleting ~/Library/Cookies/HSTS.plist, and restarting Safari will resolve the issue. This didn't work for me on macOS Sierra because the HSTS settings were being cached and the file would be recreated. In my case, I had to


  1. Quit Safari
  2. In Terminal, `rm ~/Library/Cookies/HSTS.plist`
  3. Immediately reboot before some background service reconstructed the file


I filed a report with Apple suggesting that HSTS not be saved for localhost, which isn't really a domain anyway. Don't know if they will acknowledge.

32 replies

Apr 25, 2014 3:55 PM in response to ZoeZG

In my case, yes, the problem was caused by the server that has the web site. However there might be other reasons that are unclear at the moment.


You can check whether the problem is similar to mine by going to URI Valet (just found it on Google) and entering the web address into the first input named URI. Tick the check box Check Server Headers Only, ignore all of the other inputs and click Submit.


You can try with both http and https.


You can see the header information that the server sends back to you under SERVER RESPONSE. If you see a line that reads Strict-Transport-Security you're having the same problem I had. If not there'll likely be a different cause for which I'm afraid I don't have a solution yet.

Apr 28, 2014 8:13 AM in response to ChrisJenkins

I found out how to delete the Strict Transport Security (HSTS) history from Safari since clearing the browsing history or even completely resetting Safari alone didn't work. As we know, the web server sends a time value along with the HSTS header. Safari stores those sites a file in ~/Library/Cookies/HSTS.plist. Open that file and look for your domains, they might have send that header at some point in the past. If you're domain is not listed, probably the HSTS isn't responsible for redirecting to HTTPS. If it is, you can delete it from the list doing the following:


1. Remove cookies for that domain in Settings > Privacy > Details…

You might also have clear the browsing history and/or reset Safari, unfortunately I'm not sure what worked for me.

2. Close Safari

3. Rename or delete ~/Library/Cookies/HSTS.plist


When you open Safari now and browse to your site it should work. As I said, I can't tell anymore which variation in step 1 did the trick for me. You could also try to let your web server send the HSTS header with a lifetime of 60 seconds for Safari to quickly disregard it.


The HSTS.plist is recreated some time after launching Safari and probably will still contain all the other HSTS sites that it had previously. In my case it has accounts.google.com and twitter.com among others.

Oct 15, 2014 4:12 AM in response to ChrisJenkins

No way for me too. While other "minor" browsers, such as Firefox, Chrome and Sleipnir will open the right page, Safari keeps redirecting to https, whatever you'll do: that drove me crazy without absolutely any reason on earth.

Provided that this issue will be fixed in a next release (the one included in Yosemite? I won't believe it), will the issue be persistent for users who experienced it before, like us?

Oct 15, 2014 5:47 AM in response to Streeme

Streeme, did you manage to reset the history in Safari? Since the HSTS.plist is recreated after deleting it Safari has to save those entries somewhere else., otherwise the file would be empty after recreating it. If the current Safari has some issues with following the instructions for Strict Transport Security and a future version, e.g. in Yosemite, fixes those then you should be able to access the site without being redirected. I can't tell whether Safari is faulty and it's weird that other browsers work fine. Is the web server for your site sending an HSTS header? See the instructions I posted above to check.

Nov 29, 2014 6:23 AM in response to lenn4rd

Well, I have the same problem, and it drives me nuts!


I have a debian server running an apache 2 web server, hosting toto.mydomain.com, with http and https connections. Depending on the http or https address, 2 web sites are then displayed. BUT, safari still automatically redirects me to the https address. I have tested everything mentioned above, nothing works. I have even modified the web server response to set HSTS response to 0:


> curl -I https://toto.maydomain.com

HTTP/1.1 200 OK

Date: Sat, 29 Nov 2014 13:53:48 GMT

Server: Apache/2.2.22 (Debian)

X-Powered-By: PHP/5.4.35-0+deb7u2

Set-Cookie: 52152665cd64c=s5kjtuc3muhphhu5q8lq8ovvp4; path=/; HttpOnly

Expires: Thu, 19 Nov 1981 08:52:00 GMT

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Pragma: no-cache

Strict-Transport-Security: max-age=0

X-XSS-Protection: 1; mode=block

X-Content-Type-Options: nosniff

X-Frame-Options: Sameorigin

Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; frame-src *; img-src *; font-src 'self' data:; media-src *

X-Robots-Tag: none

Vary: Accept-Encoding

Content-Type: text/html; charset=utf-8


But safari keeps redirecting me to the https version of the website.


I really don't understand what is happening.


But if I use a fresh new account on the system, this redirection does not occur any more, even if I visit the https version of the website.

So a cache, somewhere in the system, must be cleared. But which one? HSTS.plist removal has no effect here.


EDIT : the only solution I had not tried was to reboot the system after 1/ clearing the cache, 2/ deleting every entries for toto.mydomain.com from the history, and 3/ deleting HTST.plist. And ... it works now!

Jun 9, 2015 3:07 PM in response to Sylar12

Doesn't that clear all your logins and stuff from every other site you have?


Apple come on!


Look here, I have changed it: https://www.dropbox.com/s/ny2vfqat6mtrnyz/Sk%C3%A4rmklipp%202015-06-10%2000.01.3 6.png?dl=0

And then right after it changes back: https://www.dropbox.com/s/akp8zphv2dykzjs/Sk%C3%A4rmklipp%202015-06-10%2000.02.4 7.png?dl=0


I can't force Safari to visit the http version by typing it in either....


EDIT: If I use the IP however, I can choose manually, and change the bookmark... very strange...

Dec 14, 2015 6:56 AM in response to Sylar12

So I have to say that I have had no luck when it comes to resetting Safari. I actually created a brand new local user account and tried it there, but it still switches to https. I figured that I have my server configured wrong using Strict Transport Security, however that is not the case. I did, but I removed the line in the nginx config file. when I do the curl -I thingy I get this:


mbp:~ user$ curl -I http://www.domain.com

HTTP/1.1 200 OK

Server: nginx

Date: Mon, 14 Dec 2015 14:40:40 GMT

Content-Type: text/html; charset=UTF-8

Connection: keep-alive

Vary: Accept-Encoding

Set-Cookie: frontend=j0il7j0lr16fb2inuj2hsf1i66; expires=Wed, 13-Jan-2016 14:40:39 GMT; Max-Age=2592000; path=/

Expires: Thu, 19 Nov 1981 08:52:00 GMT

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Pragma: no-cache

X-Frame-Options: SAMEORIGIN

X-Config-By: LD

X-Frame-Options: SAMEORIGIN

X-Content-Type-Options: nosniff

X-XSS-Protection: 1; mode=block

X-UA-Compatible: IE=Edge,chrome=1

X-Processing-Time: 0.580



mbp:~ user$ curl -I https://www.domain.com

HTTP/1.1 200 OK

Server: nginx

Date: Mon, 14 Dec 2015 14:41:31 GMT

Content-Type: text/html; charset=UTF-8

Connection: keep-alive

Vary: Accept-Encoding

Set-Cookie: frontend=tnghb13jdn3klhffebpnvmruo1; expires=Wed, 13-Jan-2016 14:41:31 GMT; Max-Age=2592000; path=/

Expires: Thu, 19 Nov 1981 08:52:00 GMT

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Pragma: no-cache

Set-Cookie: frontend_cid=ld6irzeXL135A8Ml; expires=Wed, 13-Jan-2016 14:41:31 GMT; Max-Age=2592000; path=/; domain=www.domain.com; secure

X-Frame-Options: SAMEORIGIN

X-Config-By: LD

X-Frame-Options: SAMEORIGIN

X-Content-Type-Options: nosniff

X-XSS-Protection: 1; mode=block

X-UA-Compatible: IE=Edge,chrome=1

X-Processing-Time: 0.566



My iPhone Safari even is showing it in http://, no problem there. Chrome, Firefox... no problem, IE on Windows 10, no problem, Safari on Windows - no problem!!!!! What is going on here?

Jan 18, 2016 1:26 PM in response to ChrisJenkins

Well, we're coming up on almost two years since you first noticed this, and Apple is no closer to giving a flip about fixing it than they were back then, apparently 😠


I'm having the same problem with Safari utterly disregarding my bookmarks as entered, as well as direct entry of the URL. It seems once I visit any HTTPS page on my domain, Safari sees fit to ignore everything unsecured on that domain from that point forward.


I SHOULD NOT HAVE TO RESET MY BROWSER TO MAKE IT RESPECT MY BOOKMARKS AS ENTERED, APPLE!!! Stop trying to think FOR me and fix your broken software!

Safari forcing HTTPS for some HTTP only sites

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.