18

I'm receiving a message "Failed to load resource: The network connection was lost." in my application, which uses ajax requests to get content from server. This error is only in Safari, other browsers are ok.

I was searching last few hours and found that it can be due to http headers:

Transfer-Encoding : chunked
Connection: keep-alive
Content-Length

I've found something similar: https://github.com/woothemes/woocommerce/issues/7176 On the bottom is told that they set

BrowserMatch "Safari" nokeepalive
in .htaccess.

Is there any similar solution or settings for nginx server?

Thank you

JF

5
  • 7
    SOLVED: changed the settings of nginx server. Added keepalive_disabled for safari in config. nginx.org/en/docs/http/… Nov 25, 2015 at 11:21
  • Had the same problem in an IOS cordova/phonegap app. Thanks! Jan 28, 2016 at 16:27
  • 4
    @JakubFormanek Do we know the root cause of the issue? I see setting keepalive_disabled for safari solved the issue but do we iknow why its failing?
    – Rafthecalf
    Apr 19, 2017 at 19:43
  • 1
    I am having the same issue. Is there any solution for apache2? Jul 10, 2018 at 8:39
  • Solved with Puma: I had this problem with Safari when I made multiple AJAX requests and I have solved by removing the queue_requests from my Puma configuration. That option also has an effect on keepalive.
    – collimarco
    Mar 28, 2019 at 19:21

2 Answers 2

6

One of the reasons why it might happen is the way Safari handles some SSL certificates (mainly, LetsEncrypt). The solution is to put the line:

ssl_session_cache shared:SSL:10m;

to your nginx config.

Source: https://community.letsencrypt.org/t/apple-safari-browsers-fail-to-connect/3731/3

3
  • 1
    omg I have been searching for this answer for one hour, why is it so obscurely documented?! Apr 6, 2018 at 20:39
  • This all of the sudden starting happening on one of my app servers. Would an update from LetsEncrypt or my SSL certs cause this?
    – lsimonetti
    Jan 31, 2019 at 15:36
  • Actually, my issue wasnt SSL, it was the fact that some of the nginx files were owned by root user
    – lsimonetti
    Jan 31, 2019 at 15:47
0

Had this trouble too with a form that ajax-posted and when that completed did a window.location.reload(true). Safari 13.0.3 would work the first time after a manual page refresh (seemed consistent) then would get "Failed to load resource: The network connection was lost." roughly 2 out of 3 clicks.

Changed the client to:

  • use ajax-get instead of post (with a unique query param value each time)

  • on completion set a timer so that window.location.reload(true) was not done inside the ajax completion handler

User reports that worked, not sure which one of those changes or both.

Hope this helps someone...

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.