Spotlight hung on OS X Yosemite with 100% CPU usage

I recently upgraded from OS X Mavericks to Yosemite, and all went well except for one thing: The mds processes were constantly taking 100% CPU, resulting in decreased system performance and decreased battery life. Now I’ve been through this dance before, knowing full well that every OS X upgrade results in a Spotlight re-index to upgrade the Spotlight DB and pick up any new files. But in the past this re-index had taken at most an hour or two on my roughly 80% full 750GB SSD drive. But this time was different — Spotlight was running not for hours, but for days. I decided to let Spotlight run thinking that maybe things were different with Yosemite. After all, Spotlight was one of the big new changes highlighted by Apple in their Yosemite reveal. But after 4 days of 24×7 indexing, I decided that enough was enough and started to investigate.

There are a million different things that can go wrong with Spotlight, and plenty of articles out there on how to fix them. Some of the things I tried were:

  • Verify Disk & Verify Disk Permissions in Disk Utility
  • Fiddle with the mdutil command to disable/re-enable indexing
  • Manually removing the /.Spotlight-V100 directory so that it would be re-created
  • Adding / to Spotlight’s Privacy tab and then removing it to force a re-index.

I tried them all, and none worked.

The symptoms were simple: the mds process was constantly taking 100% CPU. I had a sneaking suspicion that it was hitting a file that it didn’t know what to do with and would just get stuck and not proceed. I was right. Using lsof I checked what files the mds process had open:

sudo lsof -c '/mds$/'

Amongst all the various /System/Library, /.Spotlight-V100, and /Volumes files and directories, I noticed a file that stuck out like a sore thumb:

/Users/MyName/Documents/Subfolder/ Player

It was actually listed twice in the lsof output. Weird, lets go check it out in Finder. Sure enough, trying to navigate there in Finder caused Finder itself to freeze up at 100% CPU usage. So I restarted Finder with Option-RightClick-Relaunch from the Dock and manually removed the file from Terminal. I then re-started Spotlight and told it to re-index from scratch:

sudo rm -rf /Users/MyName/Documents/Subfolder/
sudo launchctl unload -w /System/Library/LaunchDaemons/
sudo launchctl load -w /System/Library/LaunchDaemons/
sudo mdutil -i on -E /

This time I could see progress in the Spotlight window’s progress bar, and see files in the Spotlight DB on disk being changed and the total size increasing. About 45 minutes later Spotlight had indexed all 580GB of data. FIXED!

I have no idea why both Spotlight and Finder has trouble with this file. It was never an issue on previous versions of OS X. It was an old custom app built by a friend of mine in 2010. And while mds was stuck on the Flash Player within it, Finder crashed when navigating to directory containing the app itself. Weird.

Some helpful commands for when dealing with Spotlight:

Stop Spotlight:
sudo launchctl unload -w /System/Library/LaunchDaemons/

Start Spotlight:
sudo launchctl load -w /System/Library/LaunchDaemons/

Get the size of the Spotlight Database:
sudo du -m /.Spotlight-V100

Get a list of files opened by the MDS process:
lsof -c '/mds$/'


Turns out this troublesome file made its way onto my Time Machine backup as well, causing the *exact same issue* in Time Machine. Backups would start and get stuck on this file, causing the backupd process take up 100% CPU forever until I manually killed the backup. So if your Time Machine is exhibiting similar behaviors as described above, find out what file(s) it is barfing on with:

sudo lsof -c backupd
sudo lsof -p [PID]

Then use Time Machine’s “Delete All Backups Of…” functionality to remove it. Kick off another run of Time Machine and it should make it all the way through.

If an Apple Engineer comes across this blogpost and would like a copy of the troublesome file, hit me up.

19 responses to “Spotlight hung on OS X Yosemite with 100% CPU usage”

  1. FP says:

    Bingo! I’ve been ripping my hair over this since I’ve installed Yosemite. Thank you!!

  2. Brian Lowry says:

    Thanks so much — also had an old custom-built app that was stalling mds and a whole host of other processes, including cloning and backups (in my case the app was written by me, back in 2005 or so). Would never have figured it out without your lsof trick. Worst of all, had copied the offending file to several new desktops and new laptops over the years, and the same thing was happening on all of them (and has been for several years, variously getting worse with time). I have tried many, many cache cleanings, rebuilding of systems, hard drive, etc., optimizations, variations on Spotlight settings, but until using this I had never found the actual glitch.

  3. Brad says:

    This worked for me. Using the sudo lsof -c ‘/mds$/’ I found a backblaze installer in my volumes folder. I ejected it, re-booted and all is well. Spotlight started working instantly and my TimeMachine backups began to work again.


  4. Brandon says:

    Thanks for this. I really appreciate you making the guide; whether it was for yourself or all of us. haha.

  5. Dennis S. says:

    I reported a similar bug to Apple just after release of Yosemite. My bug got closed as duplicate. But I can see that the other one is still open. But I am not allowed to see it.

    Not good when a so important background thread gets stuck.

  6. Kevin Kendall says:

    I got home from work, laptop’s on still but sleeping. But fan’s running at 8K RPM, sounds like. I then found that I was having trouble with Spotlight in Yosemite beta on my new MB Air. I Command-Spacebar the Spotlight window up, typed something in, and absolutely nothing would show up, only what I’d just typed in. The cooling fan’s been running ALL the time for the past 3 hrs straight according to Activity Monitor, and it’s extreeeeemely unusual for the fan to be running at all. In addition, stuff’s running really sluggishly, or not at all, or weirdly.
    So I checked Activity Monitor, & chose CPU to see what’s sucking up all CPU time:
    Spotlight’s indexing process….. But why?? Spotlight’s indexing had been working great night before.
    So in Activity Monitor I highlighted MDS, and then clicked the X in the top-left of the menubar, and chose Force Quit. It went away after about 5 seconds. But came back. But at a much, much lower CPU percentage of use. And 2 or 3 MDWorker processes popped in, too. But now, less than 10 minutes after I’d killed MDS & it reappeared, the MDS process is down to 0% of CPU usage, and all the MDworker processes are at 0%, too. AND….. best of all, my Air’s finally cooling down. The fan’s stopped.
    Try it, all you MDS CPU time-sucking victims….
    End its existence.
    It’ll come back, least it did with me, but it’ll behave & act normally after it returns.
    Now I’m wondering….. what the *&^ caused that in the first place?? First time that’s ever happened….
    Good luck, allya Mac folks
    Macguy ver.1

  7. Daniel E. says:

    Awesome article! Thank you. This issue has been driving me crazy. Every site i visited and the same over an over repeated tricks, but none of them worked.

    Yours did! I found 2 entries of the same file using your sudo command. Deleted the culprit and after unload/load mds, spotlight is now once more fully indexing my drive.

    Thanks again. I hope Apple will find this article.

  8. JK Scheinberg says:

    I’m having similar but not exact spotlight problems. On my MBAir/Yosemite every few days spotlight seems to ‘go crazy’ and consume 100% cpu and slow down the system. If I put the system HD (Macintosh HD) into and out of the spotlight privacy list it seems to re-index fine and all is well. For a few days. Then the 100% usage starts again. I’d just keep spotlight off completely but then other things (like searches in don’t work. Ideas?

  9. Achi says:

    I was using sd card as a time machine backup but after some time I’ve decided to use another storage. Usign the sudo lsof -c ‘/mds$/’ I found /Volumes/Sd-card (with .Spotlight and Time Machine). Removing folders and Adding /Sd-card to Spotlight’s Privacy tab resolve the issue.

    Thanks a lot

  10. Tobias Y. says:

    Hi, I really hope that your suggestion works, but can you give a more step by step instruction on how to remove the file (and which one to remove, I could not locate this FlashPlayer file…).


  11. Camera Fiend says:

    Thank you, after trying several other options, I removed Flash Player and restarted my iMac, then miraculously Time Machine, after prior to restart ‘preparing backup’ for 26 hrs, it immediately started a full backup.

    I wanted a full new backup because of another problem (unexpected shutdowns due possibly to overheating) but wonder now if that was caused mds gobbling up resources. I shall now continue without Flash Player for a while to see what happens.

  12. I’m rebuilding my index now. I found that both Spotlight and Time Machine Backup were stuck. It seems it was caused by “/Users/rene/.Trash/obj 16.28.29/” – however my trash was empty and the folder did not exist. I managed to delete it using “sudo rm -rf /Users/rene/.Trash” after stopping Spotlight and Time Machine.

    By the way: I also had Finder crash when accessing certain folders.

    Fingers crossed it works now.

  13. Steve H says:

    Fantastic article, very clear. In my case I was suddenly getting 100% on mds for no obvious reason. The thing that stood out on the lsof command output was the Evernote install volume (the virtual disk that the .dmg makes).
    It was only there because I hadn’t bothered to remove it.
    Fixed by ejecting the volume, and then running the other 3 commands (unload, load, reindex).
    Took about 30 minutes at 100%, and now it’s back to 0% and everything is normal

    To quote Daniel E above, “Thanks again. I hope Apple will find this article.”

  14. Didier says:

    Many thanks !!!
    very usefull tip, lsof is our friend 🙂
    had the same issue since 2 days, mds hanged at 100% cpu, found 2 files with name like “-12345” in private directory, removed them with inode number and now spotlight and mds works fine.
    Thanks again

  15. ubittibu says:

    Used command:
    sudo lsof -c ‘/Dock$/’

    To solve a similar issue with Dock using 100% CPU and gigs of Virtual Memory.

    Thank you for the help!

  16. Aboghode says:

    Hey, I have the same trouble right now with El Capitan, My cpu usage is 100% (finder)
    what should I do ?

    Thank you

  17. Greg says:

    I battled this for hours, trying everything from the CoreDuetD deletion, to using OnyX to clear out caches, rebuilding indexes.

    Even the instructions here didn’t help. I removed some very old assistants from Spotlight and that didn’t work either. Finally I saw “Screw this” and upgraded to El Capitain, (which required additional trouble shooting) but now Spotlight runs correctly.

    So last resort is to upgrade… Plus, its resolved the slow reboots on my Mac Pro.

    • Heather says:

      I’ve been too afraid to upgrade having experienced serious issues with every previous upgrade on both MacBook and iPhone. I haven’t upgraded either in a couple of years now due to the issues in the previous upgrades.

  18. Heather says:

    Good info except I have no idea what you were talking about! I have never heard of this “sudo” thing that you keep mentioning. Where do I go to even start doing the steps you mentioned?

    My mds has been running non-stop for about a week and I’m tired of the mac feeling hot on my lap all the time. Spotlight is completely useless. Google says when I click on the spotlight icon it should tell me how much longer until indexing is complete. Instead all that comes up when I click the spotlight icon is a small window with a search bar and nothing else. No matter what I type in the search bar, when I hit return, nothing happens. I tried typing “indexing” and my name (should be hundreds of files with my name in them, right?) but it acts like it can’t find anything at all.

    Meanwhile the search function on my calendar has quit working as well which I assume is related.

    I think Apple needs to work a little harder at Beta testing stuff before launching. I’m seeing an alarming trend of bugs that never get fixed. Photos has never worked right and I actually talked to an Apple tech support person in April 2015 who admitted they knew it wasn’t working when they launched it. The things that weren’t working in April 2015 have not been fixed as of June 2016. Disgraceful!!!

    I can’t quit mds via the activity monitor. It just starts right back up again. So frustrated and tired of a computer using 100% of its CPU ALL the time and running hot ALL the time and processing commands I actually want it to do really, really slowly.