Just a short post for anyone who is having this particular error,

Failed to connect to the database: could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused. Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?
We received this error when we created a new user account(KL) in Kali Linux to run as, rather than use the root account.
The reason for getting this error is that the service PostgreSQL is not running on the box. So all we have to do is to start the PostgreSQL and Metasploit services.

sudo service postgresql start sudo service metasploit start
To avoid having to type this in every time you reboot the box, you can just have those two services startup at boot.
Configure PostgreSQL and Metasploit to start on startup
sudo update-rc.d postgresql enable sudo update-rc.d metasploit enable
Leave a Reply