Metasploit database cache not built

Fixing Metasploit database cache

Just a quick reminder to myself and others of how to fix the Metasploit database cache not built issue.  When we use Metasploit the search is super slow and returns the ‘slow search warning’ This where you find either the database isn’t connected or when you try to search for a vulnerability the return is ‘[!] Module database cache not built yet, using slow search’ due to the database not being connected like below: This doesn’t seem to be a huge issue and the search still works however its a fairly easy fix and makes the searching significantly quicker. I’ve posted this as I’m usually finding myself having forgotten the syntax to fix it after rebuilding a kali vm, and searching around various other posts on the internet for it, so here it is:

Module database cache not built yet, using slow search

If we check the database in Metasploit with db_status we find the below error:

Metasploit db_status

So to fix the issue:

Start the postgresql service and ensure it starts at startup:

Metasploit start service

Initialize the msf database with:

Metasploit initialize msf database

Load msfconsole and recheck the database you should find this is now connected:

Metasploit db_status connected

Finally rebuild the db cache, give it a few minutes and you should find the search instantaneous :

Metasploit db cache rebuild

et voila!