Reputation: 71
I have installed postgresql on Ubuntu 16.04, when I run psql
command this error appears:
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"?
I tried to restart and reload postgres service but the error shows every time.
Upvotes: 5
Views: 5224
Reputation: 11
Follow these steps
1) go to /var/log/postgresql
and open log file
if you see error similar to this in your log file
FATAL: private key file "/etc/ssl/private/ssl-cert-snakeoil.key"
has group or world access
DETAIL: File must have permissions u=rw (0600)
or less if owned by the database user, or permissions u=rw,g=r (0640)
or less if owned by root.
a) execute the following commands to change the permission (make sure to change the key file name if it is diff for you)
$ sudo chown postgres /etc/ssl/private/ssl-cert-snakeoil.key
$ sudo chgrp postgres /etc/ssl/private/ssl-cert-snakeoil.key
$ sudo chmod 740 /etc/ssl/private/ssl-cert-snakeoil.key
now restart the service
$ sudo /etc/init.d/postgresql restart
it should show this messge [ ok ] Restarting postgresql (via systemctl): postgresql.service.
now type these commands to verify
$ sudo su - postgres
$ psql
You should see this message
root@imp-itpl0023:/etc/ssl/private# su - postgres
postgres@imp-itpl0023:~$ psql
psql (10.3 (Ubuntu 10.3-1.pgdg16.04+1))
Type "help" for help.
Upvotes: 1
Reputation: 495
I got same errors in Ubuntu 14.04 and it worked for me. Try to restart Postgres service
$ sudo service postgresql restart
or
$ sudo /etc/init.d/postgresql restart
Upvotes: 3