11

My spotlight searching hasn't worked for quite some time and I've tried everything I could find on Google. I can't search for anything on my MacBook.. literally nothing shows up. I'll list the things I've tried and specs:

Early 2011 2.2Ghz MBP 4GB RAM OSX 10.9.4

  • disble/enable spotlight via terminal
  • toggled hidden files and looked for ".metadataneverindex" couldn't find it
  • repeated the previous, using terminal commands.. file not found
  • put everything in the preferences/privacy "prevent indexing" then removed
  • sudo mdutil -i on /

  • sudo mdutil -E /
  • sudo mdutil -a -i on
  • zapping the PRAM

Based on what Trane Francks said in the comment below.. I built the DB and ran the line again. The second line is what it returned: locate .metadata_never_index /.metadata_never_index

I found .metadata_never_index as a hidden file in my root, so I deleted it and tried reindexing.. but its giving the "Indexing and searching are disabled" message still.

I've tried many of things and every time.. I get "indexing and searching disabled."

I just wanna be able to search my mac again!! Please help! Thanks.

5
  • 1
    Just to confirm, the filename is actually '.metadata_never_index'. When I run 'locate .metadata_never_index' in Terminal, it finds the file in my recovery partition. Sep 23, 2014 at 7:55
  • I tried that and terminal returns: "WARNING: The locate database (/var/db/locate.database) does not exist. To create the database, run the following command: sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist"
    – Justin
    Oct 1, 2014 at 0:31
  • @TraneFrancks I updated my question after I updated the database and tried it again. Can I do "rm /.metadata_never_index" to delete it?
    – Justin
    Oct 1, 2014 at 0:41
  • 1
    If you want to delete a system file, you'll need to use sudo, e.g., sudo rm /.metadata_never_index. Oct 1, 2014 at 1:13
  • I wonder if this is much different than apple.stackexchange.com/questions/24401/…
    – bmike
    Mar 16, 2016 at 13:35

6 Answers 6

28

FINALLY!! I got it working again!

Heres what I did:

In terminal I ran:

locate .metadata_never_index

No database existed, so it prompted me to run:

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

It ran for a few seconds and I retried the locate command.. it found it in my root. I deleted it and tried turning on spotlight again, but still got the "indexing and searching disabled."

I checked the permissions of my SSD and my account wasn't even listed. I added myself to read/write. Then ran:

sudo mdutil -i on /

terminal returned "Indexing enabled."

Lastly.. I went to system preferences>spotlight>privacy.. dragged my SSD then removed it to reindex. 40 minutes later.. everything is back to normal! It had been a year since spotlight worked on my MBP. Ohhh the struggles I faced trying to find emails/files.

Thanks for the tips and suggestions everyone and Google!

2
  • My saviour! It was driving me nuts that I could not launch new apps from Alfred anymore. Feb 11, 2022 at 17:07
  • For macOS 11 and up, SSV is enabled, so I needed to run sudo mdutil -a -i on to get all the volumes on my mac Aug 29, 2023 at 19:31
5

Re-index an entire drive In the Terminal, type sudo mdutil -E / and hit return. You may have to enter your password. The existing Spotlight index will be deleted, and Spotlight will start creating a new index in the background. You can re-index other hard drives by changing the command to include their name, like sudo mdutil -E /Volumes/OtherHardDrive.

sudo mdutil -i off /
sudo rm -rf /.Spotlight*
sudo mdutil -i on /
sudo mdutil -E /

I'm order, these accomplish:

  1. turn indexing off
  2. delete Spotlight folder
  3. turn indexing on
  4. rebuild
1
  • 1
    It gives the "indexing and searching disabled." message when I try that
    – Justin
    Oct 1, 2014 at 0:30
5

I search for it in the net for months... and it was so easy!!

System preferences -spotilight -Privacy -if your harddisk is in the list mark it and then press (-)

When your harddisk is removed from "prevent searching this locations", you spotilight will scan your files for around 2 hours and voila!

:)

1
  • Thank you for this! Did you also run some random script you found on Github? :p
    – scorgn
    Nov 10, 2020 at 1:39
2

I just recently ran into this issue with needing to reindex my external drive in order for Spotlight and/or HoudahSpot to search files accordingly., albeit, I'm still not pulling back archives i.e., .rar, .zip, .gzip

For me, running:

sudo mdutil -a -i on

Automatically enabled and re-indexed all drives.

When I attempted to enable indexing on an external drive explicitly, I see the following:

sudo mdutil -E /Volumes/EXTERNAL_DRIVE
/Volumes/EXTERNAL_DRIVE:
2021-02-25 10:26:51.123 mdutil[5421:1461549] mdutil disabling Spotlight: /Volumes/EXTERNAL_DRIVE -> kMDConfigSearchLevelFSSearchOnly
    Indexing disabled.

Only after running sudo mdutil -a -i on was I then able to find (/var/db/locate.database) after re-indexing completed as the accepted answer suggests.

For some reason, sudo mdutil -E /Volumes/EXTERNAL_DRIVE, which should erase and rebuild the index doesn't work as expected.

HTH

3
  • How is this answer any different than the info already provided in the other answers?
    – fsb
    Feb 25, 2021 at 16:11
  • @fsb I updated my answer as others mileage may vary. I'm not disputing the accepted answer, I'm simply chiming in with the approach that worked for me.
    – ramene
    Feb 25, 2021 at 17:13
  • Thanks for updating. When I read your answer originally, it contained the same info already provided so I didn't see what was different about it.
    – fsb
    Feb 25, 2021 at 17:17
0

For people that want to re-index at the root level, based on @rename 's anwser:

sudo mdutil -a -i on /
2
  • How does this differ from ramene's answer? You're specifying a mountPoint of / but used -a for all volumes, which ramene's answer already does.
    – grg
    Nov 26, 2021 at 12:01
  • Well, i would have added this as a comment to his answer, but i cannot with only 1 point. Anyhow, the addition of the / in my case was needed; without it dit not work. Nov 27, 2021 at 13:10
0

In my case, the problem started after moving from HFS to APFS where spotlight had been disabled previous to the change. After the change, none of the mdutil commands would turn spotlight back on.

Here's what I did to fix it:

  1. Logged in as root (this might be optional). Here's how: Enable and Login as root on macos

  2. Since Catalina, the root of the system drive is read only and the non-read-only files are moved into a separate partition "(myhd)-Data". You can access those files in System/Volumes/Data . Here's some info about that change: Unable to create folder at Root and Read-only System Volume in Catalina

  3. After making sure to show hidden files in the Finder (Command + Shift + . (period)), I was able to locate the file ".metadata_never_index" in the System/Volumes/Data folder and deleted it.

  4. I also went through the short "SOLUTION" section here just to be thorough though in the end, this wasn't my particular cause.

  5. I rebooted and logged back in as root, went into terminal and entered (not sure about the order and can't be certain this was necessary - but couldn't hurt): a) mdutil -ai on b) mdutil -aE

  6. I also went into System Preferences / Spotlight / Privacy and added and then removed the system drive. This may be optional too but it couldn't hurt.

  7. BOOM - spotlight was back and doing a fresh re-index!!!

You must log in to answer this question.

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