psql: could not connect to server: Permission denied

psql: could not connect to server: Permission denied
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

This is due to PostgreSQL service unable to create .s.PGSQL.5432 file in /tmp because of insufficient permission.

You can also follow other topic:
Temporary Solution:

# chmod -R 777 /tmp/

Once done psql command will start work, but after reboot it will stop working.

# su - postgres
$ psql
psql (11.4)
Type "help" for help.

postgres=#

Permanent Solution:

# find / -name postgresql.conf
# vi /usr/local/pgsql/data/postgresql.conf

Change permission for below parameter

unix_socket_permissions = 0777

or comment below parameter in postgresql.conf

# unix_socket_permissions = 0

# service postgres stop
# service postgres start

Check if working or not

# su - postgres
$ psql
psql (11.4)
Type "help" for help.

postgres=#


You can also follow other topic:

Comments

Popular posts from this blog

[SOLVED] YUM: can not find RHNS CA file ERROR: can not find RHNS CA file: /usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT

Setting an Operating System Release During Registration

YUM Update ERROR: 28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds' Trying other mirror