everyday mac tools

Rebuild the Spotlight index on a Mac

· 6 min read

There are two ways to rebuild the Spotlight index. Add your startup disk to the Spotlight privacy list and then remove it, or run sudo mdutil -E / in Terminal. Both throw the existing index away and build a new one from scratch, and neither touches a single file of yours. Expect anything from twenty minutes to several hours, with incomplete search results the whole time.

Check that the index is the problem first

Rebuilding is a few hours of the Mac being busy, so spend two minutes confirming it is warranted.

Open Terminal and ask the index directly about a file you know exists:

mdfind -name "invoice"

mdfind reads the same index Spotlight and Finder use. If it prints the path, the index is healthy and your problem is somewhere else: a category switched off, a folder on the privacy list, or a file in a place Spotlight never looks. Spotlight cannot find a file you know exists walks that list in order, and it is much the more common cause.

Then check the volume’s status:

mdutil -s /

It reports either that indexing is enabled or that indexing and searching are disabled for that volume. Disabled is a different fix from broken, and it is covered below.

Finally, open Activity Monitor and look for mds, mds_stores and mdworker. If they are working hard, the index is being built right now, which happens after a macOS update, a Migration Assistant transfer or a restore from backup. In that case the answer is to wait rather than to start over.

Symptoms that genuinely point at a damaged index: search worked fine last week and now returns nothing for common words, Mail search comes back empty on messages you can see, or apps stop appearing when you type their names.

Method one: the privacy list

This is the version with no Terminal in it.

  1. Open System Settings, then Spotlight. On Ventura and Sonoma the pane is called Siri & Spotlight; scroll to the bottom of it.
  2. Click the privacy button at the bottom, labeled Spotlight Privacy or Search Privacy depending on your version of macOS.
  3. Click the plus button. In the file picker, press Cmd-Shift-G, type /, press Return, and select the startup disk. You can also drag the disk in from a Finder window’s sidebar.
  4. Confirm the warning that Spotlight will no longer search that location. That warning is the whole point: adding the disk discards its index.
  5. Wait a minute, then select the entry and click the minus button to remove it.
  6. Close System Settings. Indexing starts again from nothing.

The Spotlight window will show an indexing progress bar for a while afterwards. The time estimate it gives is a guess and tends to be optimistic early on.

Method two: mdutil in Terminal

Faster to type and does exactly the same thing.

sudo mdutil -E /

-E erases the index for that volume so it rebuilds. You will be asked for your login password, and nothing is echoed as you type it. To do every mounted volume at once:

sudo mdutil -a -E

To rebuild one external drive only, name its mount point:

sudo mdutil -E /Volumes/Archive

If mdutil -s reported that indexing is disabled, turn it on first, or combine both in one command:

sudo mdutil -i on -E /

One quirk worth knowing: current macOS presents the startup disk as a read-only system volume and a separate data volume mounted together. If a command complains about the path, run it against /System/Volumes/Data, which is where your files actually live.

What to expect while it rebuilds

A rebuild reads every file on the disk to work out what is in it, so the Mac will be busy.

  • Time. Twenty minutes on a modest SSD with a few hundred thousand files; several hours on a disk holding millions or on an older machine.
  • Heat and fans. Normal, and a laptop will drain quickly. Plug it in, and keep it awake: indexing pauses when the Mac sleeps, so a laptop closed after ten minutes takes days to finish in ten minute bursts.
  • Search that is worse than before. Results are incomplete until the pass finishes, and that includes Mail’s search and launching apps by name.
  • Restarts. Safe, but they do not speed anything up. Indexing resumes where it left off rather than starting again.

Leave it alone and check back. Repeatedly opening Spotlight to test progress does not help and does slow it down slightly.

When rebuilding does not fix it

If search is still wrong after a full pass, the cause was never the index.

  • The location is on the privacy list. Anything listed there is excluded permanently, and external drives end up on it more often than people expect.
  • The result category is switched off. In the same settings pane, the Search results list controls which kinds of thing appear in the Spotlight window at all.
  • The file is inside a package. The Photos library, the Mail store and application bundles are folders macOS presents as single items, and their contents never surface in normal results. Find a mail attachment on a Mac covers the attachment version of this problem.
  • The volume is not indexed. Run mdutil -s /Volumes/DriveName. Network shares are usually not indexed by your Mac at all, and neither are some disk formats.
  • The disk has a problem. Open Disk Utility, select the volume, and run First Aid. An index cannot be written reliably onto a volume with errors.
  • The disk is nearly full. Indexing needs working room, and a volume with a couple of gigabytes free will stall.

Searching while the index is down

You do not have to stop working for the afternoon. find walks the disk directly and ignores the index entirely:

find ~ -iname "*invoice*" 2>/dev/null

Slow, because it reads every folder rather than consulting a database, and thorough for the same reason. Find files by extension on a Mac covers the variations of that command.

The other option is a search tool that does not depend on Spotlight. Everywhere builds and keeps its own catalog of every filename on the Mac, so it keeps answering while Spotlight is rebuilding, and it catches up after the Mac wakes rather than falling behind. It searches names and paths only, so for a phrase you remember from inside a document you still need Spotlight, once it is well again.

Questions

Will rebuilding the index delete any of my files? No. The index is a separate database describing your files. Erasing it discards the description, and rebuilding reads your files again to write a fresh one. Nothing you created is touched at any point.

How long should it take? Long enough that you should start it when you can leave the Mac alone. The number of files matters far more than their size, so a disk full of photo libraries and project folders takes much longer than one holding a few large videos.

Should I just turn Spotlight off to save the resources? It costs more than it saves. sudo mdutil -i off / disables it, and with it goes Finder search, Mail search, and launching apps by typing their names. Indexing is intensive during the first pass and close to free afterwards.

Does this fix Mail search too? Often, because Mail relies on the same index. If Mail is still missing messages after the rebuild, use its own repair: in Mail, select the mailbox, then the Mailbox menu, then Rebuild. That reloads the mailbox from the server and can take a while on a large one.