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.
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
# cowsay++
< metasploit >
       \   ,__,
        \  (oo)____
           (__)    )\
              ||--|| *

Save 45% of your time on large engagements with Metasploit Pro
Learn more on

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

msf > db_status
[*] postgresql selected, no connection

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
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.


  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.

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

  3. 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.

  4. 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/ 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.

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

  5. 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.

  6. 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

  7. Hi, i believe that i noticed you visited my web site thus i came to return the desire?.I'm trying
    to find things to enhance my web site!I assume its good enough to use a few of your concepts!!

  8. Outstanding story there. What occurred after?
    Good luck!

  9. Article writing is also a fun, if you be familiar with after that
    you can write if not it is complex to write.



Popular Posts