I know this question has asked many times, but non of those answers worked for me.
The problem is, when I run "psql", I get the message
psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
When I run "sudo /etc/init.d/postgresql status”, it says service is running,
postgresql.service - PostgreSQL RDBMS Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled) Active: active (exited) since Tue 2018-07-10 10:51:05 +0530; 22s ago Process: 3219 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Main PID: 3219 (code=exited, status=0/SUCCESS)
But when I run “sudo lsof -i :5432” and “netstat -nltp | grep 5432” and “sudo netstat -lp --protocol=unix | grep postgres”, I gets an empty output.
Content of /etc/postgresql/9.5/main/pg_hba.conf is,
local all all peer # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5
Content of /etc/postgresql/9.5/main/postgresql.conf
hba_file = '/etc/postgresql/9.5/main/pg_hba.conf' port = 5432 listen_addresses = '*'
Finally, I uninstalled postgres using “sudo apt-get --purge remove postgresql* command and reinstalled using “apt-get install postgresql-9.5”, but the result is same.