Score:0

PostgreSQL client (psql) cannot connect after starting service with pgenv or pg_ctl

de flag

I'm able to start the service with pgenv and pg_ctl but cannot connect with psql. The following error shows:

$ psql -l
psql: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?

I checked the path of the mentioned socket but it does not exist as psql reports.

If I use pg_ctl status, the following is returned:

$ pg_ctl: server is running (PID: 2127388)
/home/postgres/Repositories/github.com/theory/pgenv/pgsql-15.2/bin/postgres

I checked the server.log file and it says that is listening on a different socket. Please see the following:

$ file /tmp/.s.PGSQL.5432
/tmp/.s.PGSQL.5432: socket

How can I troubleshoot this?

Score:0
de flag

I found the solution!

All there was to do was to create the directory /run/postgresql and assign the right permissions to that same directory. Ownership must belong to the system user account (e.g. postgres) that is executing postgresql.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.