Is the server running locally and accepting connections on Unix domain socket “/var/run/postgresql/.s.PGSQL.5432”?
If you get the above error, please follow the below steps.
Above error states that postgres is not running.
- Running
pg_lsclusters
will list all the postgres clusters running on your device.
2. Most probably the status will be down if we get the above error . Try restarting Postgres clusters and service
systemctl start postgresql@12-main
3. Check ownership of postgres. Make sure that postgres is the owner of /var/lib/postgresql/version_no/main
eg: sudo chown postgres -R /var/lib/postgresql/12/main/
The issue will be resolved with the above steps. If the issue still persists then we need to debug further.