Safari 18+ network bug - randomly - The network connection was lost
We’ve identified a recurring issue affecting our web app users on Safari 18+ (macOS and iOS). Clients have reported that some of their actions don’t go through. Initially, we couldn’t reproduce this on Chrome (Windows/Android), but after further investigation, we confirmed that the issue only occurs on Safari version 18 and above.
We tested extensively and found:
- Safari 17.0 and 17.5 work without issues.
- Safari 18+ (both real devices and simulators) intermittently fails to call our API.
- The failures are random, but over a full workday can amount to 50+ missed API calls, which is highly disruptive for professional users.
We can reproduce the issue by executing a js script that calls our API repeatedly in Safari 18+. This might be related to connection keep-alive handling, but the fact that it’s isolated to Safari 18+ and never occurs on other platforms suggests a deeper compatibility problem. Safari versions handle server settings differently? We’d appreciate any insight or guidance on how to address this issue, as it’s becoming increasingly frequent with more users upgrading.
We currently only provide HTTP/1.1 and we have keep-alive with short timeout, we handle millions on requests per day, but this "connection lost" only happens on those safari versions...
It would be our server setting that is not being handled correctly within safari, but we need to know what it is that was changed between 17.5 and 18.0 and 18.5 that might cause this problem!
The network tab on developer tools shows empty for status error, ip, connection_id etc.. its like the request is being terminated very soon, or maybe the keep alive tries to reuse a connection that the server already closed...
Running this in safari console, where a testing api endpoint is called that waits around 5 seconds:
(async () => {
for (let i = 0; i < 10; i++) {
try {
const res = await fetch(`https://api.redated.com/1/testes/probe`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
//keepalive: false
});
console.log(`Request ${i} ${new Date().toLocaleString()} status:`, res.status);
} catch (err) {
console.error(`Request ${i} ${new Date().toLocaleString()} error:`, err);
}
await new Promise(r => setTimeout(r, 900 - 1* Math.floor(Math.random() * 5))); // 250ms delay between requests
}
})();
Returns a mix of requests with success and other with faillures:
< Promise {status: "pending"}
[Log] Request 0 8/7/2025, 6:54:07 PM status: – 200
[Error] The network connection was lost.
[Error] Fetch API cannot load https://api.redated.com/1/testes/probe due to access control checks.
[Error] Failed to load resource: The network connection was lost. (probe, line 0)
[Error] Request 1 8/7/2025, 6:54:08 PM error: – TypeError: Load failed
TypeError: Load failed
Console Evaluation (Console Evaluation 14:15)
[Log] Request 2 8/7/2025, 6:54:19 PM status: – 200
[Error] The network connection was lost.
[Error] Fetch API cannot load https://api.redated.com/1/testes/probe due to access control checks.
[Error] Failed to load resource: The network connection was lost. (probe, line 0)
[Error] Request 3 8/7/2025, 6:54:20 PM error: – TypeError: Load failed
TypeError: Load failed
Console Evaluation (Console Evaluation 14:15)
[Log] Request 4 8/7/2025, 6:54:32 PM status: – 200
[Error] The network connection was lost.
[Error] Fetch API cannot load https://api.redated.com/1/testes/probe due to access control checks.
[Error] Failed to load resource: The network connection was lost. (probe, line 0)
[Error] Request 5 8/7/2025, 6:54:33 PM error: – TypeError: Load failed
TypeError: Load failed
Console Evaluation (Console Evaluation 14:15)
[Log] Request 6 8/7/2025, 6:54:44 PM status: – 200
[Error] The network connection was lost.
[Error] Fetch API cannot load https://api.redated.com/1/testes/probe due to access control checks.
[Error] Failed to load resource: The network connection was lost. (probe, line 0)
[Error] Request 7 8/7/2025, 6:54:45 PM error: – TypeError: Load failed
TypeError: Load failed
Console Evaluation (Console Evaluation 14:15)
[Log] Request 8 8/7/2025, 6:54:57 PM status: – 200
[Error] The network connection was lost.
[Error] Fetch API cannot load https://api.redated.com/1/testes/probe due to access control checks.
[Error] Failed to load resource: The network connection was lost. (probe, line 0)
[Error] Request 9 8/7/2025, 6:54:58 PM error: – TypeError: Load failed
TypeError: Load failed
Console Evaluation (Console Evaluation 14:15)
I see many other users reporting issues with network and URLSession however this is web page in safari.
Has anyone else feeling the same increase in network errors only for safari? Because we are...
Thanks.
iPhone 16