0

Instead of using /usr/local/pgsql/data, I create my database cluster with the following code

initdb -D /tmp/psql
pg_ctl -D /tmp/psql -l logfile -o "--unix_socket_directories='$PWD'" start

But when I run psql, I get the following error.

psql: error: 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"?

I have read the doc and I cannot find related options for changing the location for database cluster. What have I missed?

1
  • Add to your question the connection string you are using with psql. In meantime I'm guessing the issue is you are not using a -h in the connection string and psql is falling back to the compiled in default for the socket directory. To override this in the connection string see libpq under host. Commented Jul 6, 2021 at 14:53

1 Answer 1

1

I ran into the same issue and specifying the socket directory with the -h option fixes the issue.

psql -h $PWD -p 5432 postgres

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.