Technology and troubleshooting.

Sunday, September 11, 2016

How to fix metasploit failed to connect to the database

This tutorial describes How to fix metasploit failed to connect to the database in Kali Linux2.0 Sana .

My scenario:- Today i did some experimental with Kali Linux Sana. I tired to connect metasploit database with postgresql it failed to connect database these is the error i got during experimental.
Error:-
root@kali:~# service postgresql start
root@kali:~# service postgresql status
postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; disabled)
   Active: active (exited) since Sun 2016-09-11 16:44:35 IST; 48min ago
  Process: 6448 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 6448 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/postgresql.service
root@kali:~# service metasploit start
Failed to start metasploit.service: Unit metasploit.service failed to load: No such file or directory.


  root@kali:~# msfconsole
                                                  ole.../
# cowsay++
 ____________
< metasploit >
 ------------
       \   ,__,
        \  (oo)____
           (__)    )\
              ||--|| *



Save 45% of your time on large engagements with Metasploit Pro
Learn more on http://rapid7.com/metasploit

       =[ metasploit v4.11.4-2015071403                   ]
+ -- --=[ 1467 exploits - 840 auxiliary - 232 post        ]
+ -- --=[ 432 payloads - 37 encoders - 8 nops             ]
+ -- --=[ Free Metasploit Pro trial: http://r-7.co/trymsp ]

msf > db_status
[*] postgresql selected, no connection


Solution:-
Here is the solution to fix metasploit failed to connect to the database.
root@kali:~# /usr/bin/msfconsole
msf > msfdb init
[*] exec: msfdb init
msf > msfconsole
[*] exec: msfconsole
msf > db_status
[*] postgresql connected to msf
              [OR]
root@kali:~# /usr/bin/msfconsole start
msf > db_status
[*] postgresql connected to msf
I hope this information is useful for you. Please forgive any typos or incomplete sentences.
Share: