Search code examples
postgresqlgreenplumhawq

Greenplum Database :psql: could not connect to server: No such file or directory


I am bashing my head against the wall. its been 4 days.but psql is not connecting.

We have a small array of Greenplum database.In that, We have the master node. when i am trying to use psql utility

Getting this error :

[gpadmin@master gpseg-1]$ psql
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"?

We tried

on searching for postmaster.pid files.

We have removed it.But still, error remains.


Solution

  • Use a command like ( netstat -ln; ps -ef ) | egrep '(postgres)|(postmaster)|(5432)' to try to determine whether or not an instance of the postgres server is running.

    If the postmaster is not running, remove the postmaster.pid file and restart the database. While I don't use the Greenplum database, I see that instructions are here: Starting and Stopping the Greenplum Database. Do not remove the postmaster.pid file without making sure the database is not running, and note that removing the postmaster.pid file without starting the database is pointless.

    It may be wise to open your postgresql.conf file and see if the listen_addresses, port, unix_socket_directory, unix_socket_group, and unix_socket_permissions settings might be a source of issues.

    Since the error message referenced specifically mentions the socket file, look most closely at unix_socket_directory, unix_socket_group, and unix_socket_permissions.

    If unix_socket_directory is pointing somewhere other than /tmp, then various workarounds exist.

    Alternatively, and presuming that the server is running, one might try to locate the socket file without looking in the postgresql.conf file, though this might make it a bit harder to address permissions, port, etc. issues. A tool like locate, find, etc., may be used in conjunction with sudo or by the root user.

    $ sudo find /tmp /var -name .s.PGSQL.5432
    

    Presuming that the location of the .s.PGSQL.5432 file issue is the root cause of your problem, specifying the socket file location on the psql command-line is probably the most straightforward workaround. In example, if the *.s.PGSQL.5432 file is in /var/pgsql_socket directory as it is on some systems, try this, but, of course, use the actual directory where .s.PGSQL.5432 is located:

    $ pgsql -h /var/pgsql_socket
    

    If the .s.PGSQL.5432 file IS in /tmp, then the problem is more likely one of permissions, and consulting the postgresql.conf file is advised, and probably the user attempting the psql command will have to be added to a group that has access to the socket file. (Remember, log out and back in after changing group membership.)

    Though the page does not necessarily seem to directly relate to this issue, do consider the Accessing the Database help as needed.