pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
permission denied on socket
9+ messages / 5 participants
[nested] [flat]

* permission denied on socket
@ 2024-01-25 20:22  Atul Kumar <akumar14871@gmail.com>
  0 siblings, 3 replies; 9+ messages in thread

From: Atul Kumar @ 2024-01-25 20:22 UTC (permalink / raw)
  To: pgsql-general <pgsql-general@lists.postgresql.org>

Hi,

I have postgres 13 running on centos 7.

I am facing an issue while trying to connect the cluster using the below
command.

-bash-4.2$ psql postgres

psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed:
Permission denied

        Is the server running locally and accepting connections on that
socket?


but when I am trying to connect using the below command I am able to login
to the cluster successfully.

-bash-4.2$ psql postgres -h localhost

postgres=#


I am not sure what is causing this issue and what needs to be done to
resolve it ?


Regards.

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: permission denied on socket
@ 2024-01-25 20:32  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Atul Kumar <akumar14871@gmail.com>
  2 siblings, 1 reply; 9+ messages in thread

From: Adrian Klaver @ 2024-01-25 20:32 UTC (permalink / raw)
  To: Atul Kumar <akumar14871@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>

On 1/25/24 12:22, Atul Kumar wrote:
> Hi,
> 
> I have postgres 13 running on centos 7.
> 
> I am facing an issue while trying to connect the cluster using the below 
> command.
> 
> -bash-4.2$ psql postgres
> 
> psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: 
> Permission denied

With the Postgres server running does:

/tmp/.s.PGSQL.5432

exist?

> 
> Is the server running locally and accepting connections on that socket?
> 
> 
> but when I am trying to connect using the below command I am able to 
> login to the cluster successfully.
> 
> -bash-4.2$ psql postgres -h localhost
> 
> postgres=#

The above works because you are not connecting to local(the socket), but 
to localhost(127.0.0.1 or ::1).

> 
> 
> I am not sure what is causing this issue and what needs to be done to 
> resolve it ?

Best guess is you are using a version of psql that is expecting the 
socket to be somewhere else then where it actually is.

> 
> 
> Regards.
> 
> 
> 

-- 
Adrian Klaver
adrian.klaver@aklaver.com






^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: permission denied on socket
@ 2024-01-25 20:32  Ron Johnson <ronljohnsonjr@gmail.com>
  parent: Atul Kumar <akumar14871@gmail.com>
  2 siblings, 0 replies; 9+ messages in thread

From: Ron Johnson @ 2024-01-25 20:32 UTC (permalink / raw)
  To: pgsql-general <pgsql-general@lists.postgresql.org>

On Thu, Jan 25, 2024 at 3:23 PM Atul Kumar <akumar14871@gmail.com> wrote:

> Hi,
>
> I have postgres 13 running on centos 7.
>
> I am facing an issue while trying to connect the cluster using the below
> command.
>
> -bash-4.2$ psql postgres
>
> psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed:
> Permission denied
>
>         Is the server running locally and accepting connections on that
> socket?
>
>
> but when I am trying to connect using the below command I am able to login
> to the cluster successfully.
>
> -bash-4.2$ psql postgres -h localhost
>
> postgres=#
>
>
> I am not sure what is causing this issue and what needs to be done to
> resolve it ?
>

psql explicitly tells you the problem:
    socket "/tmp/.s.PGSQL.5432" failed: *Permission denied*
Did you look at the permissions on /tmp/.s.PGSQL.5432?

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: permission denied on socket
@ 2024-01-25 20:39  Ron Johnson <ronljohnsonjr@gmail.com>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 2 replies; 9+ messages in thread

From: Ron Johnson @ 2024-01-25 20:39 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Atul Kumar <akumar14871@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>

On Thu, Jan 25, 2024 at 3:32 PM Adrian Klaver <adrian.klaver@aklaver.com>
wrote:
[snip]

> Best guess is you are using a version of psql that is expecting the
> socket to be somewhere else then where it actually is.
>

Is "permission denied" really the error you get when the socket does not
exist?

Trying "psql --host=/var/run/foo" gave me "No such file or directory".

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: permission denied on socket
@ 2024-01-25 21:14  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Ron Johnson <ronljohnsonjr@gmail.com>
  1 sibling, 0 replies; 9+ messages in thread

From: Adrian Klaver @ 2024-01-25 21:14 UTC (permalink / raw)
  To: Ron Johnson <ronljohnsonjr@gmail.com>; +Cc: Atul Kumar <akumar14871@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>


On 1/25/24 12:39 PM, Ron Johnson wrote:
> On Thu, Jan 25, 2024 at 3:32 PM Adrian Klaver 
> <adrian.klaver@aklaver.com> wrote:
> [snip]
>
>     Best guess is you are using a version of psql that is expecting the
>     socket to be somewhere else then where it actually is.
>
>
> Is "permission denied" really the error you get when the socket does 
> not exist?
>
> Trying "psql --host=/var/run/foo" gave me "No such file or directory".


The OP used:

psql postgres

In that case psql will use the default set when it is compiled against 
libpq which from here:

https://www.postgresql.org/docs/16/libpq-connect.html#LIBPQ-PARAMKEYWORDS

"... is to connect to a Unix-domain socket in |/tmp| (or whatever socket 
directory was specified when PostgreSQL was built)"


If you have more then one instance of psql on a machine and they where 
built with different defaults you can

end up not hitting the right socket.

Also "permission denied" could be due to any part of the path 
/tmp/.s.PGSQL.5432.

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: permission denied on socket
@ 2024-01-25 21:30  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Ron Johnson <ronljohnsonjr@gmail.com>
  1 sibling, 1 reply; 9+ messages in thread

From: Tom Lane @ 2024-01-25 21:30 UTC (permalink / raw)
  To: Ron Johnson <ronljohnsonjr@gmail.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; Atul Kumar <akumar14871@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>

Ron Johnson <ronljohnsonjr@gmail.com> writes:
> On Thu, Jan 25, 2024 at 3:32 PM Adrian Klaver <adrian.klaver@aklaver.com>
> wrote:
>> Best guess is you are using a version of psql that is expecting the
>> socket to be somewhere else then where it actually is.

> Is "permission denied" really the error you get when the socket does not
> exist?

Nope, that should mean either that /tmp is not readable, or that the
socket file is there but has restrictive permissions.

That doesn't necessarily make Adrian's answer wrong though.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: permission denied on socket
@ 2024-01-26 02:40  Atul Kumar <akumar14871@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 9+ messages in thread

From: Atul Kumar @ 2024-01-26 02:40 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Ron Johnson <ronljohnsonjr@gmail.com>; Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general <pgsql-general@lists.postgresql.org>

I checked the permissions on /tmp directory and it shows "drwxrwxrwt."
already, do I need to check something else as well ?

Regards.

On Fri, Jan 26, 2024 at 3:00 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Ron Johnson <ronljohnsonjr@gmail.com> writes:
> > On Thu, Jan 25, 2024 at 3:32 PM Adrian Klaver <adrian.klaver@aklaver.com
> >
> > wrote:
> >> Best guess is you are using a version of psql that is expecting the
> >> socket to be somewhere else then where it actually is.
>
> > Is "permission denied" really the error you get when the socket does not
> > exist?
>
> Nope, that should mean either that /tmp is not readable, or that the
> socket file is there but has restrictive permissions.
>
> That doesn't necessarily make Adrian's answer wrong though.
>
>                         regards, tom lane
>

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: permission denied on socket
@ 2024-01-26 03:45  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Atul Kumar <akumar14871@gmail.com>
  0 siblings, 0 replies; 9+ messages in thread

From: Tom Lane @ 2024-01-26 03:45 UTC (permalink / raw)
  To: Atul Kumar <akumar14871@gmail.com>; +Cc: Ron Johnson <ronljohnsonjr@gmail.com>; Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general <pgsql-general@lists.postgresql.org>

Atul Kumar <akumar14871@gmail.com> writes:
> I checked the permissions on /tmp directory and it shows "drwxrwxrwt."
> already, do I need to check something else as well ?

That seems fine, but what about the socket file itself?

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: permission denied on socket
@ 2024-01-26 18:34  pf@pfortin.com
  parent: Atul Kumar <akumar14871@gmail.com>
  2 siblings, 0 replies; 9+ messages in thread

From: pf@pfortin.com @ 2024-01-26 18:34 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

On Fri, 26 Jan 2024 01:52:58 +0530 Atul Kumar wrote:

>        Is the server running locally and accepting connections on that
>socket?

Maybe this will help:

# ss -l | grep 5432





^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2024-01-26 18:34 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-01-25 20:22 permission denied on socket Atul Kumar <akumar14871@gmail.com>
2024-01-25 20:32 ` Adrian Klaver <adrian.klaver@aklaver.com>
2024-01-25 20:39   ` Ron Johnson <ronljohnsonjr@gmail.com>
2024-01-25 21:14     ` Adrian Klaver <adrian.klaver@aklaver.com>
2024-01-25 21:30     ` Tom Lane <tgl@sss.pgh.pa.us>
2024-01-26 02:40       ` Atul Kumar <akumar14871@gmail.com>
2024-01-26 03:45         ` Tom Lane <tgl@sss.pgh.pa.us>
2024-01-25 20:32 ` Ron Johnson <ronljohnsonjr@gmail.com>
2024-01-26 18:34 ` pf@pfortin.com

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox