Safari cannot open the page. Error: Failed to navigate to an HTTP URL with HTTPS-only mode enabled.

I am currently operating an app using an embedded web server that communicates over local HTTP.

Recently, when opening Safari, I started encountering the following error message:

"Safari cannot open the page. Error: Failed to navigate to an HTTP URL with HTTPS-only mode enabled."

However, I am currently in a situation where switching to HTTPS is difficult. Are there any solutions to resolve this issue besides using HTTPS?

Thank you.🙏

Answered by DTS Engineer in 824213022

I was talking about iOS

OK. Sorry about the confusion; nothing in either of your posts indicating that [1]. And running a local HTTP server on iOS can be challenging, depending on your specific requirements.

I think it’s best if we focus this discussion on your other thread. I’ll reply there shortly.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] I recommend that you have a read of Quinn’s Top Ten DevForums Tips.

Please note that I am using the loopback address (127.0.0.1)!

I presume that this is on the Mac. If so, Safari is able to connect to localhost using HTTP. Consider this:

  1. Start a local ‘server’ in Terminal:

    % nc -l 12345
    
  2. In Safari, paste http://127.0.0.1:12345 into the address field and press return.

  3. Back in Terminal, marvel at the incoming HTTP request:

    % nc -l 12345
    GET / HTTP/1.1
    Host: 127.0.0.1:12345
    Sec-Fetch-Dest: document
    User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.2 Safari/605.1.15
    Upgrade-Insecure-Requests: 1
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Sec-Fetch-Site: none
    Sec-Fetch-Mode: navigate
    Accept-Language: en-GB,en;q=0.9
    Priority: u=0, i
    Accept-Encoding: gzip, deflate
    Connection: keep-alive    
    

I’m testing on macOS 15.2 but AFAICT this works the same in all recent releases.

One thing to note is that there’s testable feature called “HTTPS-by-default (HTTPS-First)” that will change this behaviour. You can try it out in Safari > Settings > Feature Flags. I think it’ll fall back to HTTP after HTTPS fails, but I’m not really up-to-speed on it.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I was talking about iOS

OK. Sorry about the confusion; nothing in either of your posts indicating that [1]. And running a local HTTP server on iOS can be challenging, depending on your specific requirements.

I think it’s best if we focus this discussion on your other thread. I’ll reply there shortly.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] I recommend that you have a read of Quinn’s Top Ten DevForums Tips.

Safari cannot open the page. Error: Failed to navigate to an HTTP URL with HTTPS-only mode enabled.
 
 
Q