pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
error on connecting port 5432
12+ messages / 5 participants
[nested] [flat]

* error on connecting port 5432
@ 2020-12-01 08:51 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 14:26 ` Re: error on connecting port 5432 Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Atul Kumar @ 2020-12-01 08:51 UTC (permalink / raw)
  To: pgsql-general

Hi,

When I m creating a test db user using below command using root OS user
 sudo -u postgres createuser -p 5432 --pwprompt testuser

I am getting the attached error of port.

But my postgres services are running fine on port 5432, I am sharing
the screenshot of that also.

So please help me in letting me know why I am getting the above error
when I am connected to the root OS user?

Note - I am able to create a test db user when I am connected to
postgres using psql command.


Regards,
Atul

Attachments:

error_1.PNG (image/png, 11.3K) download view image
psql.PNG (image/png, 10.1K) download view image
^ permalink raw reply [nested|flat] 12+ messages in thread

* Re: error on connecting port 5432
  2020-12-01 08:51 error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
@ 2020-12-01 14:26 ` Adrian Klaver <adrian.klaver@aklaver.com>
  2020-12-01 14:32   ` Re: error on connecting port 5432 Adrian Klaver <adrian.klaver@aklaver.com>
  2020-12-01 16:10   ` Re: error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  0 siblings, 2 replies; 12+ messages in thread

From: Adrian Klaver @ 2020-12-01 14:26 UTC (permalink / raw)
  To: Atul Kumar <akumar14871@gmail.com>; pgsql-general

On 12/1/20 12:51 AM, Atul Kumar wrote:
> Hi,
> 
> When I m creating a test db user using below command using root OS user
>   sudo -u postgres createuser -p 5432 --pwprompt testuser
> 
> I am getting the attached error of port.
> 
> But my postgres services are running fine on port 5432, I am sharing
> the screenshot of that also.

In future please include this as text not images.

> 
> So please help me in letting me know why I am getting the above error
> when I am connected to the root OS user?

You are not connecting as OS root you are connecting as the database 
user testuser.

Does /var/run/postgresql/.s.PGSQL.5432 exits?

Do you have more then one instance of Postgres on this machine?

If so how where they installed and more importantly where they installed 
differently?

As a test try running the command with addition of -h localhost.

> 
> Note - I am able to create a test db user when I am connected to
> postgres using psql command.
> 
> 
> Regards,
> Atul
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





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

* Re: error on connecting port 5432
  2020-12-01 08:51 error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 14:26 ` Re: error on connecting port 5432 Adrian Klaver <adrian.klaver@aklaver.com>
@ 2020-12-01 14:32   ` Adrian Klaver <adrian.klaver@aklaver.com>
  1 sibling, 0 replies; 12+ messages in thread

From: Adrian Klaver @ 2020-12-01 14:32 UTC (permalink / raw)
  To: Atul Kumar <akumar14871@gmail.com>; pgsql-general


On 12/1/20 6:26 AM, Adrian Klaver wrote:
> On 12/1/20 12:51 AM, Atul Kumar wrote:
>> Hi,
>>
>> When I m creating a test db user using below command using root OS user
>>   sudo -u postgres createuser -p 5432 --pwprompt testuser
>>
>> I am getting the attached error of port.
>>
>> But my postgres services are running fine on port 5432, I am sharing
>> the screenshot of that also.
> 
> In future please include this as text not images.
> 
>>
>> So please help me in letting me know why I am getting the above error
>> when I am connected to the root OS user?
> 
> You are not connecting as OS root you are connecting as the database 
> user testuser.
> 
> Does /var/run/postgresql/.s.PGSQL.5432 exits?

Does /var/run/postgresql/.s.PGSQL.5432 exist?

> 
> Do you have more then one instance of Postgres on this machine?
> 
> If so how where they installed and more importantly where they installed 
> differently?
> 
> As a test try running the command with addition of -h localhost.
> 
>>
>> Note - I am able to create a test db user when I am connected to
>> postgres using psql command.
>>
>>
>> Regards,
>> Atul
>>
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





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

* Re: error on connecting port 5432
  2020-12-01 08:51 error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 14:26 ` Re: error on connecting port 5432 Adrian Klaver <adrian.klaver@aklaver.com>
@ 2020-12-01 16:10   ` Atul Kumar <akumar14871@gmail.com>
  2020-12-01 16:53     ` Re: error on connecting port 5432 Tom Lane <tgl@sss.pgh.pa.us>
  2020-12-01 18:15     ` Re: error on connecting port 5432 Adrian Klaver <adrian.klaver@aklaver.com>
  1 sibling, 2 replies; 12+ messages in thread

From: Atul Kumar @ 2020-12-01 16:10 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: pgsql-general

Hi,

Just to clarify that I am at root OS user, trying to create a test user
using postgres user(-u) with create user command.

Error screenshots are already shared with you.

Please re-check the same.





Regards
Atul



On Tuesday, December 1, 2020, Adrian Klaver <adrian.klaver@aklaver.com>
wrote:

> On 12/1/20 12:51 AM, Atul Kumar wrote:
>
>> Hi,
>>
>> When I m creating a test db user using below command using root OS user
>>   sudo -u postgres createuser -p 5432 --pwprompt testuser
>>
>> I am getting the attached error of port.
>>
>> But my postgres services are running fine on port 5432, I am sharing
>> the screenshot of that also.
>>
>
> In future please include this as text not images.
>
>
>> So please help me in letting me know why I am getting the above error
>> when I am connected to the root OS user?
>>
>
> You are not connecting as OS root you are connecting as the database user
> testuser.
>
> Does /var/run/postgresql/.s.PGSQL.5432 exits?
>
> Do you have more then one instance of Postgres on this machine?
>
> If so how where they installed and more importantly where they installed
> differently?
>
> As a test try running the command with addition of -h localhost.
>
>
>> Note - I am able to create a test db user when I am connected to
>> postgres using psql command.
>>
>>
>> Regards,
>> Atul
>>
>>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
>

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

* Re: error on connecting port 5432
  2020-12-01 08:51 error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 14:26 ` Re: error on connecting port 5432 Adrian Klaver <adrian.klaver@aklaver.com>
  2020-12-01 16:10   ` Re: error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
@ 2020-12-01 16:53     ` Tom Lane <tgl@sss.pgh.pa.us>
  2020-12-02 06:03       ` Re: error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-02 07:02       ` Re: error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  1 sibling, 2 replies; 12+ messages in thread

From: Tom Lane @ 2020-12-01 16:53 UTC (permalink / raw)
  To: Atul Kumar <akumar14871@gmail.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general

Atul Kumar <akumar14871@gmail.com> writes:
> Just to clarify that I am at root OS user, trying to create a test user
> using postgres user(-u) with create user command.

Given the reference to /var/run/postgresql, I'm suspecting that you
are running a server that thinks it should put its socket in /tmp,
but you have some copies of libpq on the machine that were built with
default socket location /var/run/postgresql.  When you are root, you
are very likely using a different PATH that is finding a different
createuser program linked to a different libpq.so than when you are
not root.

A possible workaround is to add "-h /tmp" to your command when
running as root.  Eventually you'd want to try to not have
multiple postgres installations on the machine.

			regards, tom lane





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

* Re: error on connecting port 5432
  2020-12-01 08:51 error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 14:26 ` Re: error on connecting port 5432 Adrian Klaver <adrian.klaver@aklaver.com>
  2020-12-01 16:10   ` Re: error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 16:53     ` Re: error on connecting port 5432 Tom Lane <tgl@sss.pgh.pa.us>
@ 2020-12-02 06:03       ` Atul Kumar <akumar14871@gmail.com>
  2020-12-02 06:14         ` Re: error on connecting port 5432 David G. Johnston <david.g.johnston@gmail.com>
  1 sibling, 1 reply; 12+ messages in thread

From: Atul Kumar @ 2020-12-02 06:03 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general

hi,

There is no directory of postgresql in /var/run.

Please help me out.



Regards,
Atul




On 12/1/20, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Atul Kumar <akumar14871@gmail.com> writes:
>> Just to clarify that I am at root OS user, trying to create a test user
>> using postgres user(-u) with create user command.
>
> Given the reference to /var/run/postgresql, I'm suspecting that you
> are running a server that thinks it should put its socket in /tmp,
> but you have some copies of libpq on the machine that were built with
> default socket location /var/run/postgresql.  When you are root, you
> are very likely using a different PATH that is finding a different
> createuser program linked to a different libpq.so than when you are
> not root.
>
> A possible workaround is to add "-h /tmp" to your command when
> running as root.  Eventually you'd want to try to not have
> multiple postgres installations on the machine.
>
> 			regards, tom lane
>





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

* Re: error on connecting port 5432
  2020-12-01 08:51 error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 14:26 ` Re: error on connecting port 5432 Adrian Klaver <adrian.klaver@aklaver.com>
  2020-12-01 16:10   ` Re: error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 16:53     ` Re: error on connecting port 5432 Tom Lane <tgl@sss.pgh.pa.us>
  2020-12-02 06:03       ` Re: error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
@ 2020-12-02 06:14         ` David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 0 replies; 12+ messages in thread

From: David G. Johnston @ 2020-12-02 06:14 UTC (permalink / raw)
  To: Atul Kumar <akumar14871@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general

On Tuesday, December 1, 2020, Atul Kumar <akumar14871@gmail.com> wrote:
>
> There is no directory of postgresql in /var/run.


Wasn’t expecting there to be, that’s what you get the error.


> Please help me out.
>

Since “su - postgres” works for psql just do that for createuser.

Or do what Tom said and specify -h /tmp in your commands

It might be interesting to see what “which psql” shows in each case; or
whether psql works in the sudo -u case.

David J.

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

* Re: error on connecting port 5432
  2020-12-01 08:51 error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 14:26 ` Re: error on connecting port 5432 Adrian Klaver <adrian.klaver@aklaver.com>
  2020-12-01 16:10   ` Re: error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 16:53     ` Re: error on connecting port 5432 Tom Lane <tgl@sss.pgh.pa.us>
@ 2020-12-02 07:02       ` Atul Kumar <akumar14871@gmail.com>
  2020-12-02 07:09         ` Re: error on connecting port 5432 Andreas Schmitz <mailinglist@longimanus.net>
  2020-12-02 07:20         ` Re: error on connecting port 5432 David G. Johnston <david.g.johnston@gmail.com>
  2020-12-02 15:31         ` Re: error on connecting port 5432 Adrian Klaver <adrian.klaver@aklaver.com>
  1 sibling, 3 replies; 12+ messages in thread

From: Atul Kumar @ 2020-12-02 07:02 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general

Thanks a lot Tom, I appended the -h /tmp and it worked.

I need just one more help from you.

Could you tell me that why & how that socket file existed in /tmp directory.

What is the practice to make sure that this file (.s.PGSQL.5432)
should be inside /var/run directory ? so that it will not throw such
error.

Please help me.






Regards,
Atul



On 12/1/20, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Atul Kumar <akumar14871@gmail.com> writes:
>> Just to clarify that I am at root OS user, trying to create a test user
>> using postgres user(-u) with create user command.
>
> Given the reference to /var/run/postgresql, I'm suspecting that you
> are running a server that thinks it should put its socket in /tmp,
> but you have some copies of libpq on the machine that were built with
> default socket location /var/run/postgresql.  When you are root, you
> are very likely using a different PATH that is finding a different
> createuser program linked to a different libpq.so than when you are
> not root.
>
> A possible workaround is to add "-h /tmp" to your command when
> running as root.  Eventually you'd want to try to not have
> multiple postgres installations on the machine.
>
> 			regards, tom lane
>





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

* Re: error on connecting port 5432
  2020-12-01 08:51 error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 14:26 ` Re: error on connecting port 5432 Adrian Klaver <adrian.klaver@aklaver.com>
  2020-12-01 16:10   ` Re: error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 16:53     ` Re: error on connecting port 5432 Tom Lane <tgl@sss.pgh.pa.us>
  2020-12-02 07:02       ` Re: error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
@ 2020-12-02 07:09         ` Andreas Schmitz <mailinglist@longimanus.net>
  2 siblings, 0 replies; 12+ messages in thread

From: Andreas Schmitz @ 2020-12-02 07:09 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

You might want to give
https://www.postgresql.org/docs/13/runtime-config-connection.html a read

regards

Andreas

Am 12/2/2020 um 8:02 AM schrieb Atul Kumar:
> Thanks a lot Tom, I appended the -h /tmp and it worked.
>
> I need just one more help from you.
>
> Could you tell me that why & how that socket file existed in /tmp directory.
>
> What is the practice to make sure that this file (.s.PGSQL.5432)
> should be inside /var/run directory ? so that it will not throw such
> error.
>
> Please help me.
>
>
>
>
>
>
> Regards,
> Atul
>
>
>
> On 12/1/20, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Atul Kumar <akumar14871@gmail.com> writes:
>>> Just to clarify that I am at root OS user, trying to create a test user
>>> using postgres user(-u) with create user command.
>> Given the reference to /var/run/postgresql, I'm suspecting that you
>> are running a server that thinks it should put its socket in /tmp,
>> but you have some copies of libpq on the machine that were built with
>> default socket location /var/run/postgresql.  When you are root, you
>> are very likely using a different PATH that is finding a different
>> createuser program linked to a different libpq.so than when you are
>> not root.
>>
>> A possible workaround is to add "-h /tmp" to your command when
>> running as root.  Eventually you'd want to try to not have
>> multiple postgres installations on the machine.
>>
>> 			regards, tom lane
>>
>





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

* Re: error on connecting port 5432
  2020-12-01 08:51 error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 14:26 ` Re: error on connecting port 5432 Adrian Klaver <adrian.klaver@aklaver.com>
  2020-12-01 16:10   ` Re: error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 16:53     ` Re: error on connecting port 5432 Tom Lane <tgl@sss.pgh.pa.us>
  2020-12-02 07:02       ` Re: error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
@ 2020-12-02 07:20         ` David G. Johnston <david.g.johnston@gmail.com>
  2 siblings, 0 replies; 12+ messages in thread

From: David G. Johnston @ 2020-12-02 07:20 UTC (permalink / raw)
  To: Atul Kumar <akumar14871@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general

On Wednesday, December 2, 2020, Atul Kumar <akumar14871@gmail.com> wrote:

> Thanks a lot Tom, I appended the -h /tmp and it worked.
>
> I need just one more help from you.
>
> Could you tell me that why & how that socket file existed in /tmp
> directory.
>

Because the server was configured that way:


https://www.postgresql.org/docs/current/runtime-config-connection.html#RUNTIME-CONFIG-CONNECTION-SET...

See: unix_socket_directories

Thing is, the client code doesn’t read the postgresql.conf configuration
file - it just knows its own compile-time default.  For some reason, your
client in one mode was compiled using a different default than the server
on the same machine. From which we infer you have two client installs on
your machine, each compiled using different defaults.

David J.

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

* Re: error on connecting port 5432
  2020-12-01 08:51 error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 14:26 ` Re: error on connecting port 5432 Adrian Klaver <adrian.klaver@aklaver.com>
  2020-12-01 16:10   ` Re: error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 16:53     ` Re: error on connecting port 5432 Tom Lane <tgl@sss.pgh.pa.us>
  2020-12-02 07:02       ` Re: error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
@ 2020-12-02 15:31         ` Adrian Klaver <adrian.klaver@aklaver.com>
  2 siblings, 0 replies; 12+ messages in thread

From: Adrian Klaver @ 2020-12-02 15:31 UTC (permalink / raw)
  To: Atul Kumar <akumar14871@gmail.com>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general

On 12/1/20 11:02 PM, Atul Kumar wrote:
> Thanks a lot Tom, I appended the -h /tmp and it worked.
> 
> I need just one more help from you.
> 
> Could you tell me that why & how that socket file existed in /tmp directory.
> 
> What is the practice to make sure that this file (.s.PGSQL.5432)
> should be inside /var/run directory ? so that it will not throw such
> error.
> 
> Please help me.

We have been trying, but you have not provided the information necessary 
to come up with a solution.

So once again:

What OS and version?

Do you have more then one instance of Postgres on this machine?

Where did you get your Postgres code/packages from?


> 
> 
> 
> 
> 
> 
> Regards,
> Atul
> 
> 
Adrian Klaver
adrian.klaver@aklaver.com





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

* Re: error on connecting port 5432
  2020-12-01 08:51 error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
  2020-12-01 14:26 ` Re: error on connecting port 5432 Adrian Klaver <adrian.klaver@aklaver.com>
  2020-12-01 16:10   ` Re: error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
@ 2020-12-01 18:15     ` Adrian Klaver <adrian.klaver@aklaver.com>
  1 sibling, 0 replies; 12+ messages in thread

From: Adrian Klaver @ 2020-12-01 18:15 UTC (permalink / raw)
  To: Atul Kumar <akumar14871@gmail.com>; +Cc: pgsql-general

On 12/1/20 8:10 AM, Atul Kumar wrote:
> Hi,
> 
> Just to clarify that I am at root OS user, trying to create a test user 
> using postgres user(-u) with create user command.

No you are not at root for the OS you are at OS user postgres connecting 
as database user testuser.


> 
> Error screenshots are already shared with you.

What I was saying is that the error message as text is better. You can 
copy and paste from a terminal session.

You have not answered the other questions about the status of your 
Postgres install(s). The suspicion is that you have a mixed install and 
are having PATH issues. See Tom's response also.

> 
> Please re-check the same.
> 
> 
> 
> 
> 
> Regards
> Atul
> 
> 
> 
> On Tuesday, December 1, 2020, Adrian Klaver <adrian.klaver@aklaver.com 
> <mailto:adrian.klaver@aklaver.com>> wrote:
> 
>     On 12/1/20 12:51 AM, Atul Kumar wrote:
> 
>         Hi,
> 
>         When I m creating a test db user using below command using root
>         OS user
>            sudo -u postgres createuser -p 5432 --pwprompt testuser
> 
>         I am getting the attached error of port.
> 
>         But my postgres services are running fine on port 5432, I am sharing
>         the screenshot of that also.
> 
> 
>     In future please include this as text not images.
> 
> 
>         So please help me in letting me know why I am getting the above
>         error
>         when I am connected to the root OS user?
> 
> 
>     You are not connecting as OS root you are connecting as the database
>     user testuser.
> 
>     Does /var/run/postgresql/.s.PGSQL.5432 exits?
> 
>     Do you have more then one instance of Postgres on this machine?
> 
>     If so how where they installed and more importantly where they
>     installed differently?
> 
>     As a test try running the command with addition of -h localhost.
> 
> 
>         Note - I am able to create a test db user when I am connected to
>         postgres using psql command.
> 
> 
>         Regards,
>         Atul
> 
> 
> 
>     -- 
>     Adrian Klaver
>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





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


end of thread, other threads:[~2020-12-02 15:31 UTC | newest]

Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-12-01 08:51 error on connecting port 5432 Atul Kumar <akumar14871@gmail.com>
2020-12-01 14:26 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-12-01 14:32   ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-12-01 16:10   ` Atul Kumar <akumar14871@gmail.com>
2020-12-01 16:53     ` Tom Lane <tgl@sss.pgh.pa.us>
2020-12-02 06:03       ` Atul Kumar <akumar14871@gmail.com>
2020-12-02 06:14         ` David G. Johnston <david.g.johnston@gmail.com>
2020-12-02 07:02       ` Atul Kumar <akumar14871@gmail.com>
2020-12-02 07:09         ` Andreas Schmitz <mailinglist@longimanus.net>
2020-12-02 07:20         ` David G. Johnston <david.g.johnston@gmail.com>
2020-12-02 15:31         ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-12-01 18:15     ` Adrian Klaver <adrian.klaver@aklaver.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