This morning when searching for a module in Metasploit I received the dreaded error:
Database not connected or cache not built, using slow search
Surprisingly, there was very little information on forums or other blogs regarding this in the context of Kali 2.0 – so I’ll document my fix here.
Further to the above error, entering the command ‘db_status‘ returns:
postgresql selected, no connection
The solution: to create a new database and connect metasploit to it. But first, the postgresql service must be started and set to auto-start:
service postgresql start
update-rc.d postgresql enable
The database can then be created:
createuser msf_user –P
createdb –owner=msf_user msf_database
… and Metasploit configured to point to the newly created database:
This will automatically initiate a rebuild of the module cache (the equivalent of running update_db_cache).