#26 Metasploit cannot connect to Postgresql DB

WTF v2.0
pending
Raul Siles
None
5
2013-05-01
2012-09-08
Raul Siles
No

If msfconsole is run with sudo (same as from the menu) a DB error shows up:
[-] Failed to connect to the database: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 7337?

John Bize provided troubleshooting details for this issue on the SamuraiWTF mailing list:

  1. Add the following start script using sudo: /etc/init.d/metasploit-postgresql

!/bin/sh

exec /usr/share/metasploit/ctlscript.sh "$@" postgresql

  1. Change the script permissions:
    $ sudo chmod 755 /etc/init.d/metasploit-postgresql

  2. Run:
    $ sudo update-rc.d metasploit-postgresql defaults

  3. Restart the system.

This will be fixed in 2.1.

Discussion