This is what I enter:
user@user-computer:/usr/lib/postgresql/9.4/bin$ ./postgres -D /etc/postgresql/9.4/main/
This is what I get:
[4173-1] FATAL: could not access private key file "/etc/ssl/private/ssl-cert-snakeoil.key": Permission denied
Can anyone help me? should I change permissions on ss-cert...key file?
The error happens because you're trying to launch PostgreSQL as your own unpriviledged user, and it's not meant to run like that.
Ubuntu provides PostgreSQL packaged in a way that it should be launched with:
$ sudo /etc/init.d/postgresql start
# or
$ sudo service postgresql start
or for finer-grained control with pg_ctlcluster
, see
http://manpages.ubuntu.com/manpages/trusty/man8/pg_ctlcluster.8.html
This can happen when the postgres
user doesnt belong to ssl-cert
usergroup
Try adding postgres
user to the group ssl-cert
make sure that postgres
is the owner of /var/lib/postgresql/version_no/main
eg: sudo chown postgres -R /var/lib/postgresql/9.6/main/
Run the below code to fix the usergroup issue and fixing the permissions
# > It happened to me and it turned out that I removed erroneously the postgres user from "ssl-cert" group, set it back with
sudo gpasswd -a postgres ssl-cert
# Fixed ownership and mode
sudo chown root:ssl-cert /etc/ssl/private/ssl-cert-snakeoil.key
sudo chmod 740 /etc/ssl/private/ssl-cert-snakeoil.key
# now postgresql starts! (and install command doesn't fail anymore)
sudo service postgres restart
#also try running pg_ctlcluster <version> <cluster> <action>
sudo pg_ctlcluster 9.6 main start
courtsey to GabLeRoux