Fix metasploit “Database not connected or cache not built”

Posted by

This is a short post explaining how to deal with metasploit instance not connected to its database (I’m using the new Kali Linux but it is the same for Backtrack 5). The issue usually surfaces when you try to search auxiliary or exploit.
Assuming that you use msfconsole you get something like this:

msf > search oracle
[!] Database not connected or cache not built, using slow search

The error says that there are 2 probable causes of the problem
– either your metasploit framework is not connected to its database (postgresql instance called msf3 by default)
– or the metasploit cache was not built.
To check if the database is connected you can use db_status command. If your database is connected you will get:

msf > db_status
[*] postgresql connected to msf3

If the database is connected you can skip the next step and go directly to “Step 2: Build the cache”.

Stpe 1: Start up PostgreSQL and Metasploit services

If the database is not connected exit your metasploit console and start both postgresql and metasploit services using the following commands:

#service postgresql start
#service metasploit start

Note: if you are using user different then root make sure that he has the privilege level to start those services

Start PostgreSQL and Metasploit Services

After you’ve dealt with both services start the msfconsole again and check if the database is connected using db_status again.

Note: If you want to start the postgresql and metasploit services on each reboot you need to use update-rc.d

#update-rc.d postgresql enable
#update-rc.d metasploit enable

Stpe 2: Build the cache

To build/rebuild metasploit cache use db_rebuild_cache command:

msf > db_rebuild_cache

It takes some time for the cache to be rebuild so be patient.

If all went OK you can now enjoy fast auxiliary/exploit search 🙂

26 responses

  1. kwonka bomera Avatar
    kwonka bomera
  2. null Avatar
    null
  3. Alexandre Avatar
    Alexandre
  4. Alan Jackson Avatar
    Alan Jackson
  5. Ethiical Hacker Avatar
    Ethiical Hacker
  6. Nelk Avatar
  7. anil Avatar
    anil
    1. ePsiLoN Avatar
      ePsiLoN
  8. m15t3rx Avatar
    m15t3rx
  9. Anakin Skywalker (CL) Avatar
    Anakin Skywalker (CL)
  10. John Avatar
    John
  11. romeo Avatar
    romeo
  12. Nazir Avatar
    Nazir
  13. sp0ne Avatar
    sp0ne
  14. anil Avatar
    anil
    1. Max Avatar
      Max
      1. ePsiLoN Avatar
        ePsiLoN
  15. dan Avatar
    dan
  16. Peter Lustig Avatar
    Peter Lustig
  17. Loukas Avatar
    Loukas
  18. Lorenz111 Avatar
    Lorenz111
  19. malinda Avatar
    malinda
  20. Burned_Chicken Avatar
    Burned_Chicken
  21. sanket Avatar
    sanket
  22. John Daly Avatar
    John Daly
  23. illialoo99 Avatar
    illialoo99

Leave a Reply

Your email address will not be published. Required fields are marked *