First, open the terminal and run the following command:
ps auxw | grep postgres
If there is no process named postgres, then the database is not running. If this is the case, enter the following command on your terminal:
sudo service postgresql restart
Casp is running, check the permissions of the /var/run/postgresql/
directory, see if the postgres user has read / write permission. If you do not have this permission, use the following command:
sudo chown postgres /var/run/postgresql/
If it still does not work, locate and check your postgres.conf file, look for the line that defines the socket, and edit this line with the path /var/run/postgresql