psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket “/tmp/.s.PGSQL.5432”?

First check if PostgreSQL is running on the server using ps command.
#ps aux | grep postgre
postgres 4335 2.4 0.2 27704 2936 ?     S  12:07 0:00 /usr/bin/postmaster -p 5432 -D /var/lib/pgsql/data
postgres 4337 0.0 0.0  9972  548 ?     S  12:07 0:00 postgres: logger process
postgres 4339 0.0 0.0 27704  804 ?     S  12:07 0:00 postgres: writer process
postgres 4340 0.0 0.0 10972  544 ?     S  12:07 0:00 postgres: stats buffer process
postgres 4341 0.0 0.0 10148  668 ?     S  12:07 0:00 postgres: stats collector process
root     4346 0.0 0.0  3912  676 pts/5 S+ 12:07 0:00 grep postgre
If you get the above results, it means PostgreSQL is running locally on the server.
Then check parameter “unix_socket_directory” in the PostgreSQL configuration file
(var/lib/pgsql/data/postgresql.conf) and set it to “/tmp/”
ie, unix_socket_directory =”/tmp/”
Then restart PostgreSQL using PostgreSQL daemon or script
#/etc/init.d/postgresql restart or /scripts/restartsrv_postgresql

About Sarath

A Techie from Kochi, India with 8+ years of experience in Linux and Windows server administration. I learn new things almost everyday and I enjoy the fun of learning and sharing my knowledge.

Related Posts

COMMENTS

Leave a Reply

Your email address will not be published. Required fields are marked *