1

I noticed that spotlight was using a lot of CPU and I did not have time to debug it, so I disabled spotlight with this command:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

Now I want to reenable spotlight and debug why it is non-stop indexing my drive, but I can't figure out how to reenable it.

$ sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
/System/Library/LaunchDaemons/com.apple.metadata.mds.plist: service already loaded

But when I search for anything I get "No Results".

Here is my configuration:

Spotlight System Preferences - Search Results Spotlight System Preferences - Privacy

How do I get indexing reenable?

[EDIT]

I tried one of the suggested answers with this result:

 % sudo mdutil -a -i off
Password:
/:
2020-09-03 15:35:44.980 mdutil[33360:1381738] mdutil disabling Spotlight: / -> kMDConfigSearchLevelFSSearchOnly
    Indexing disabled.
/System/Volumes/Data:
2020-09-03 15:35:45.026 mdutil[33360:1381738] mdutil disabling Spotlight: /System/Volumes/Data -> kMDConfigSearchLevelFSSearchOnly
    Indexing disabled.
/Volumes/MBP15 Time Machine:
2020-09-03 15:35:45.060 mdutil[33360:1381738] mdutil disabling Spotlight: /Volumes/MBP15 Time Machine -> kMDConfigSearchLevelFSSearchOnly
    Indexing enabled. (Indexing level may not be changed on volumes which have a Time Machine backup)
/Volumes/MBP15 Time Machine/Backups.backupdb:
2020-09-03 15:35:49.728 mdutil[33360:1381738] mdutil disabling Spotlight: /Volumes/MBP15 Time Machine/Backups.backupdb -> kMDConfigSearchLevelFSSearchOnly
    Indexing enabled.
 % sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
/System/Library/LaunchDaemons/com.apple.metadata.mds.plist: Operation not permitted while System Integrity Protection is engaged
 % sudo mdutil -a -i on
/:
    Indexing enabled.
/System/Volumes/Data:
    Indexing enabled.
/Volumes/MBP15 Time Machine:
    Indexing enabled.
/Volumes/MBP15 Time Machine/Backups.backupdb:
    Indexing enabled.
1
  • Note that the load and unload subcommands have been deprecated and the about the replacements can be read here.
    – scribe
    Commented Sep 1 at 2:38

2 Answers 2

6

Open Terminal window from LaunchPad.

First, turn off Spotlight:

sudo mdutil -a -i off 

Next, unload the metadata file that controls Spotlight’s index:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist 

Use the following command to re-loads the index :

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

As a last step, turn Spotlight back on:

sudo mdutil -a -i on 

After a few minutes to rebuild the index, Spotlight should be functioning as normal.

1
  • 1
    This worked but I think only the last command is necessary. The sudo launchctl unload failed for me as Operation not permissed. Commented Sep 3, 2020 at 19:46
0

Had the above problem on Catalina 10.15.7. I don't use iCloud. Turned on WireShark and ran sudo mdutil -avi on and noticed that there was activity with gateway.icloud.com.

I added the following line to my /etc/hosts file.

127.0.0.1 gateway.icloud.com

This effectively blocks/re-routes all traffic to that site locally. This immediately fixed the re-indexing problem for me.

Those that use iCloud may want to comment out that line after indexing works again, for me, I'll leave it like that.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .