"psql: could not connect to server: No such file or directory"
On a debian system, postgresql files and directories should be owned by user postgres
, in group postgres
, with permissions of either 0700
(directories) or 0600
(files).
If they're not that, you can repair perms & ownership with:
sudo chown -R postgres:postgres /var/lib/postgresql/9.4/
sudo chmod -R u=rwX,go= /var/lib/postgresql/9.4/
Note the capital X
in the chmod
command. Unlike a lowercase x
, that will set the execute bit only on directories and on files that are already executable (there shouldn't be any of those in the pg directories).
and then restart the postgresql service.