Re: BUG #16086: Cannot connect using psql, however I can connectusing pgadmin - Mailing list pgsql-bugs

From Muziwandile Zwane
Subject Re: BUG #16086: Cannot connect using psql, however I can connectusing pgadmin
Date
Msg-id DB6P189MB032531E61A31BE9D9A8B6167B4610@DB6P189MB0325.EURP189.PROD.OUTLOOK.COM
Whole thread Raw
In response to Re: BUG #16086: Cannot connect using psql, however I can connectusing pgadmin  (Jeff Janes <jeff.janes@gmail.com>)
Responses Re: BUG #16086: Cannot connect using psql, however I can connectusing pgadmin
List pgsql-bugs
Hi Jeff, thanks for the reply, I have found where I went wrong.
I am very new in the PSQL world, I am an oracle dba by profession.

I wanted to change the port from default to 5437, initially it worked, but suddendly I had issues connecting.
I changed the port postgresql.conf back to 5432.

[root@zardplpsmasdev01 data]# su - postgres -c "psql"
psql (12.0)
Type "help" for help.

postgres=#


From: Jeff Janes <jeff.janes@gmail.com>
Sent: Tuesday, 29 October 2019 13:27
To: PG Bug reporting form <noreply@postgresql.org>
Cc: pgsql-bugs <pgsql-bugs@lists.postgresql.org>; mzwai99@outlook.com <mzwai99@outlook.com>
Subject: Re: BUG #16086: Cannot connect using psql, however I can connect using pgadmin
 

LOG:  listening on Unix socket "/u01/postgresql/.s.PGSQL.5437"
LOG:  listening on Unix socket "/tmp/.s.PGSQL.5437"

...


[root@zardplpsmasdev01 ~]# su - postgres -c "psql"
psql: error: could not connect to server: 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"?

You probably have multiple binaries installed coming from different packages or package managers.  psql is searching for the socket in one place, which is not either of the two places the server is listening.  You could explicitly tell it where to connect with either `-h /tmp`, or `-h 127.0.0.1`.  Or you could find the correct "psql" to run (the one that came with the running server) so that it just knows where to look, possibly uninstalling the wrong psql to minimize future confusion.

Cheers,

Jeff

pgsql-bugs by date:

Previous
From: Ashutosh Sharma
Date:
Subject: Re: BUG #16086: Cannot connect using psql, however I can connectusing pgadmin
Next
From: Tom Lane
Date:
Subject: Re: Backup/restore problem