Matthew Price

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 from OS X 10.10 (Yosemite) to 10.11 (El Capitan); 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 9.0 Settings

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 five files in that folder related to storing your history. You should close Safari and then delete all of them: History.db, History.db-lock, History.db-shm, History.db-wal, and HistoryIndex.sk.2

Contents of ~/Library/Safari/

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

  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