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:

11 comments:

  1. hello!,I like your writing so a lot! share we keep in touch more approximately your article
    on AOL? I need an expert on this area to unravel my problem.
    Maybe that is you! Taking a look ahead to peer you.

    ReplyDelete
  2. Awesome article.

    ReplyDelete
  3. This is a topic that's near to my heart... Many thanks!
    Where are your contact details though?

    ReplyDelete
  4. root@kali:~# service metasploit start
    Job for metasploit.service failed because the control process exited with error code.

    See "systemctl status metasploit.service" and "journalctl -xe" for details.

    ReplyDelete
  5. root@kali:~# systemctl status metasploit.service
    ● metasploit.service - LSB: Metasploit RPC and web daemons
    Loaded: loaded (/etc/init.d/metasploit; generated)
    Active: failed (Result: exit-code) since Mon 2019-05-27 02:40:15 IST; 2min 35s ago
    Docs: man:systemd-sysv-generator(8)
    Process: 10014 ExecStart=/etc/init.d/metasploit start (code=exited, status=127)

    May 27 02:40:15 kali systemd[1]: Starting LSB: Metasploit RPC and web daemons...
    May 27 02:40:15 kali metasploit[10014]: /etc/init.d/metasploit: 15: exec: /opt/metasploit/ctlscript.sh: not found
    May 27 02:40:15 kali systemd[1]: metasploit.service: Control process exited, code=exited, status=127/n/a
    May 27 02:40:15 kali systemd[1]: metasploit.service: Failed with result 'exit-code'.
    May 27 02:40:15 kali systemd[1]: Failed to start LSB: Metasploit RPC and web daemons.

    ReplyDelete
    Replies
    1. Hello DDTech,
      Can you please share the output of "journalctl -xe" operating system flavor as well?

      Delete
  6. Wonderful items from you, man. I've be mindful your stuff previous
    to and you are simply extremely fantastic. I really like what you have bought right here,
    certainly like what you are saying and the way during which you assert it.
    You are making it enjoyable and you still care for to
    stay it smart. I cant wait to read much more from you.
    This is actually a tremendous site.

    ReplyDelete
  7. 1.apt purge armitage metasploit-framework

    2.remove /opt/metasploit-framework
    3.remove /usr/share/metasploit-framework
    4.remove /home/.msf4

    5.apt install armitage metasploit-framework

    i did this my problem solved

    ReplyDelete

Popular Posts