MP

A Fix for Safari Forgetting Your History

For the last few months, Safari would forget bits of my browsing history every time I closed it. After around 24 hours only one or two items would be left listed for the previous day of browsing. There was no logic to what was being remembered or how quickly history items would disappear.

I upgraded OS X; I disabled all my Safari extensions; I cleared out the cache, cookies, and the few items left in History; I turned off syncing Safari to iCloud in System Preferences; I closed every application and background process I found running; I checked to make sure that “remove history items” wasn’t set to “after one day”1 and I even changed it to “manually” to see if there was a bug. Nothing worked.

Screenshot of Safari's preferences

If you’re here it probably means googling hasn’t been helpful: most search results are for people who want to disable history tracking. I feel your pain, but hopefully you’re in luck.

Solution

My problem stemmed from a corrupted database in ~/Library/Safari/. There are four or five files in that folder related to storing your history, depending on your OS version. You should close Safari and then delete all of them: History.db, History.db-lock, History.db-shm, History.db-wal, and HistoryIndex.sk (if it exists).2

Screenshot of Safari's Library folder

With any luck, you should now be able to open Safari, load a website, and then close Safari without it losing your history.

Updates

  • Screenshots and instructions updated for macOS 10.15 (Catalina), although I haven’t needed to do this again since publishing the article. — 31 May 2020
  1. This was officially the most common suggestion, and it started to become infuriating. That said: go check it just to be safe. It’s the most common for a reason. 

  2. The easiest way to open that folder is:

    1. Open Finder
    2. Press Cmd+Shift+G
    3. Type ~/Library/Safari/
    4. Press Go