Somehow I always seem to have database connection issues with Metasploit, so I put together this page for myself. Maybe you too will find it useful.

UPDATE 1/20/2016
Kali linux 2.x has a new way to fix database connection issues that makes fixing this once troublesome issue extremely easy.

  1. Check your database connection status in metasploit by running

    db_status inside metasploit

    If you are not connected then exit metasploit and then…

  2.  Use msfdb to fix your connection issues
    Running msfdb init should start your database.

Open msfconsole to check to see if your connection issues are resolved, if not then try the steps listed below.

Everything from this point forward is more geared towards pre 2.x kali linux … but the steps may still be helpful. If you can’t fix your connection issues with msfdb then proceed.


First, you can check your database connection in msfconsole by running db_status


As you can see in the picture I have no connection.

Next, you will want to make sure that the postgresql and metasploit services are running:


As you can see, mine are running. It may be helpful to restart the services by running

Next, you will want to view your database.yml file by taking a look at:

You should see something like what is shown below in the picture.

Next, you can try to connect to this database listed in your database.yml by using any of the listed syntax options.

After this try checking your connection status in metasploit

If after attempting to connect to the database manually you still cannot achieve a connection, you need to check your framework.log

Scroll through this log file and you should see entries for your failed login attempts with details that may aid you in solving any troubles.

It may also be helpful to use netstat to make sure nothing else is running on the same port as postgresql.


Eventually you will get to this

If you still cant connect you’re welcome to leave a comment below or ask your question in the metasploit community forums.