Step 3: If the service is running but you don 't see a socket Then, try connecting via psql using this file's location explicitly, eg.
If postgres is running and accepting socket connections, the above should tell you the location of the socket. Use find to search for the location of the socket, which should be somewhere in the /tmp Step 2: If the postgres service is running You can look at all the options available to start the postgres server using the following.įrom there, you 'd see that the options -D and -r are respectively the datadir & the logfilename.
The last column shows the command used to start the server, and the options. But on most *ix systems the following would work, it will search for postgres among all running processesĥ01 408 1 0 2Jul15 ? 0:21.63 /usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres -r /usr/local/var/postgres/server.log The command may vary depending on your operating system. Step 1: Verify that the database is running Either you don't have the database service running in the background, or the socket is located elsewhere, or perhaps the pg_hba.conf needs to be fixed. Example 1: psql: 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"? The error states that the psql utility can 't find the socket to connect to your database server.