I got a MacBook from my work and wanted to use the locate command, but I get the message:

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

Please be aware that the database can take some time to generate; once
the database has been created, this message will no longer appear.

I ran sudo launchctl and waited some time... It's been two days and I still see that same message. If I ran sudo launchctl again I get:

/System/Library/LaunchDaemons/com.apple.locate.plist: service already loaded

Searched for the database and:

$ ls -l /var/db/locate.database
ls: /var/db/locate.database: No such file or directory

The com.apple.locate.plist file is set with the predefined schedule to update on every Saturday at 3:15


So, it shall update once it was executed for the first time. I'm under Mojave (v10.14.2), new MacBook with SSD and Core i7. locate should take few minutes to work on new machines, but it's not the case here.

Any ideas on why it isn't working and/or how to make it work?

  • 3
    As I see in the plist, you can run sudo /usr/libexec/locate.updatedb in order to build the db earlier. BTW You can use mdfind command to search for files quicker (It uses Spotlight database). Feb 5, 2019 at 19:57

2 Answers 2


Amigo, I might start with launchctl:

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

Then check for any impediments to obtaining exclusive lock privilege on the nonexistent database:

sudo fuser -fu /private/var/db/locate.database
sudo lsof /private/var/db/locate.database

Then kill any process reported by either command. Next, run the db generator by hand, preceded by an opensnoop for debugging if something goes wrong. You will need to open a new terminal window ( command key - N shortcut, I believe ) and run opensnoop there, exiting it with a Control Key - c combo.

sudo opensnoop -cegx -f /private/var/db/locate.database 

Then over to your original window type:

sudo /usr/libexec/locate.updatedb

Remember to quit opensnoop with a cntrl-c in its window.



I was using the MacBook for about three weeks and just put it to sleep everyday. For some unknown reason locate was not working. To solve the issue, it helped the classical "have you tried to turn it on and off?" After restart, it worked.

As already mentioned, locate is configured to update its database every Saturday, so it doesn't find any new file created before it updates. A workaround is to set the .plist file for everyday updates.

And as @mateusz-szlosek suggested, the command mdfind is more efficient and can find recently created files using the option -name.


You must log in to answer this question.

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