Mac's 49.7 day limit: apple's hidden reboot requirement

Apple's macOS system has a sneaky limitation that can catch users off guard. After exactly 49 days, 17 hours, 2 minutes, and 47 seconds of continuous operation, several parts of the network may stop functioning, even though the system appears to be running normally.

Photon uncovers the issue

According to a report from Photon, which uses a large number of Macs to monitor iMessage services, the problem was first noticed when some machines suddenly stopped accepting new connections while still reporting everything as fine. To resolve the issue, Photon's teams had to restart the affected Macs, only to see the same pattern repeat.

Curious about the cause, Photon's engineers set up scripts to recreate the problem in a controlled environment, eventually discovering the root of the issue: a 32-bit unsigned integer counter called tcp_now within macOS's network stack.

Countdown to reboot

Countdown to reboot

This counter tracks the system uptime from a TCP/IP perspective, with a maximum value of 4,294,967,295 milliseconds, equivalent to approximately 49.7 days. When the counter reaches this limit, it simply resets to zero, rather than handling the rollover properly.

Apple's XNU kernel fails to implement a correct reset, instead keeping the counter at its maximum value and blocking the logic for closing connections. This ultimately causes the network to run out of available temporary ports, becoming stuck and unable to create new connections, even though the system appears to be functioning.

A familiar problem

A familiar problem

This issue is not unique to macOS, as Windows 98 also suffered from similar problems due to 32-bit integer overflows after extended periods of uptime.

Solution and future fixes

Solution and future fixes

For now, the only solution is to restart the affected Macs before they reach the 49.7-day mark. This presents a significant problem for servers and monitoring systems that should ideally run continuously. Apple appears to be actively working on a fix, with Photon collaborating to ensure a timely and optimized resolution.