How to fix Contacts not syncing in macOS
There are all sorts of little ways Apple's services can stop working correctly if you ever change the primary email address on your Apple Account. Here's one I ran into. A few months ago, one of my Macs stopped getting new iCloud contacts. My other devices kept syncing just fine. It turns out the Mac still had my old email address in its iCloud Contacts settings, even though System Settings showed the new one.
Here's how I fixed it on macOS 27.2.1 without signing out of iCloud.
How to verify you have the same problem
-
Check that a missing contact shows up on another device and in Contacts on iCloud.com. Make sure iCloud Contacts is enabled on the Mac. Apple's troubleshooting steps are a good place to start
-
Open Console and look for
AddressBookSourceSync. My logs showedFailed to get a X-mobile me token, HTTP401, andNSURLErrorDomain Code=-1012. One failed request to*-contacts.icloud.comhad my old email address in the URL. Josh Long saw the same thing -
If you want to check the account records directly, run the query below in Terminal. On my machine, the
AppleAccountrow had my current address and bothCardDAVrows had the old one/usr/bin/sqlite3 -readonly "$HOME/Library/Accounts/Accounts4.sqlite" <<'SQL' SELECT t.ZIDENTIFIER, a.ZUSERNAME FROM ZACCOUNT a JOIN ZACCOUNTTYPE t ON a.ZACCOUNTTYPE = t.Z_PK WHERE a.ZACCOUNTDESCRIPTION = 'iCloud' AND a.ZACTIVE = 1 AND t.ZIDENTIFIER IN ('com.apple.account.AppleAccount', 'com.apple.account.CardDAV'); SQL
How I fixed it
Signing out of iCloud and back in worked for Josh and some people on Reddit and MacRumors. I wanted to stay signed in, so I had Codex make a much smaller change. This involves editing macOS's private Internet Accounts database, so only try it if the query shows the same mismatch.
- Quit Contacts. If you're using an agent to do this for you, give it temporary Full Disk Access
- Use SQLite's backup API to make a private backup of
~/Library/Accounts/Accounts4.sqlite. Check that the backup opens and passesPRAGMA quick_check. Test the edit on a copy first - Update
ZACCOUNT.ZUSERNAMEfor the two active iCloudcom.apple.account.CardDAVrecords linked to your Apple Account. CheckZACCOUNTPROPERTYfor those same records. On my Mac, the old address was also in the archiveduserName,AccountURL,HomeInfo, andPrincipalInfo/principalInfoproperties. Decode those binary plists, replace the old address in the relevant strings (including the URL-encoded form), and re-encode them. Apply the changes together in one SQLite transaction - Run
launchctl kickstart "gui/$(id -u)/com.apple.AddressBook.SourceSync"and reopen Contacts. Once the sync ran, my missing contact showed up and the logs showed iCloud accepting the requests. Check for a contact you knew was missing, and you'll have verified the fix
I miss the days when I believed the lie that Macs were unlike Windows PCs because they didn't inevitably get bogged down with cruft like this shit, but it is indeed a lie. I wish Apple were more committed to preventing and remediating the kind of data corruption that occurs over time with each of their devices (and backups of those devices, and iCloud databases…). But, at least we have now have coding agents to do what Apple don't.