Metasploit Cheatsheet

Setup the Database

service postgresql start
kali msfdb init

Test it:

msfconsole
db_status

You'll know it worked if you see [*] postgresql connected to msf.
Resource: https://docs.kali.org/general-use/starting-metasploit-framework-in-kali

Troubleshooting database connectivity issues

Start by restarting the postgres service:
service postgresql restart

If that doesn't work, try destroying and recreating the database:

msfdb delete
msfdb init

Then test it:

msfconsole
db_status

Resource: https://stackoverflow.com/questions/32561760/metasploit-cant-use-default-msf3-to-connect