Re: IPV6 issue

From: Atul Kumar <akumar14871(at)gmail(dot)com>
To: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Subject: Re: IPV6 issue
Date: 2023-11-27 20:11:43
Message-ID: CA+ONtZ7hGMKZDZHg4SVecZ3+mkPDwcey-P8wr7PTJSsrJ_e0eA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I found that localhost was set to .bash_profile and when I removed it and
then re-attempted to connected the database using "psql postgres", I got
this new error:

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

So DO I need to restart the postgres service or is there any other
workaround?

Regards.

On Fri, Nov 24, 2023 at 1:08 AM Ron Johnson <ronljohnsonjr(at)gmail(dot)com> wrote:

> On Thu, Nov 23, 2023 at 2:18 PM Atul Kumar <akumar14871(at)gmail(dot)com> wrote:
>
>> I have postgres 12 running in centos 7 on my two machines, recently I
>> changed the authentication of entries of pg_hba.conf to scram-sha-256 for
>> localhost.
>>
>> Since then in my one machine, I have started getting the below error when
>> I use command "psql postgres"
>>
>> no pg_hba.conf entry for host "::1", user "postgres", database "postgres
>>
>>
>> I found that localhost is resolve to IPV6 by using below command:
>>
>> getent hosts localhost
>>
>> ::1 localhost localhost.localdomain localhost6
>> localhost6.localdomain6
>>
>>
>> Then I tested the same issue in my second machine
>>
>> getent hosts localhost
>>
>> ::1 localhost localhost.localdomain localhost6
>> localhost6.localdomain6
>>
>>
>> but in my second machine I didn't face any such issue while using command
>> "psql postgres", I was able to login into the database without such error.
>>
>>
>> The pg_hba.conf on both machines are identical without having any IPV6
>> entry in it.
>>
>>
>> The entry of pg_hba.conf is like below:
>>
>> # TYPE DATABASE USER ADDRESS METHOD
>>
>>
>>
>> # "local" is for Unix domain socket connections only
>>
>> local all all
>> scram-sha-256
>>
>> # IPv4 local connections:
>>
>> host all postgres 127.0.0.1/32
>> scram-sha-256
>>
>>
>> I am not able to understand that my both machines are resolved to IPV6
>> then why is my first machine is throwing this error ?
>>
>
> That *is *curious.
>
> Have you exported PGHOST on either server (in, for example,
> .pgsql_profile, .bash_profile or .bashrc)? If it is set to localhost on
> the primary server then psql will complain like you noticed. If it is
> unset on the secondary server, then psql will use the domain socket and not
> complain.
>
>

In response to

  • IPV6 issue at 2023-11-23 19:18:25 from Atul Kumar

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2023-11-27 20:31:07 Re: IPV6 issue
Previous Message Laurenz Albe 2023-11-27 18:58:13 Re: Could not read from file "pg_subtrans/00F5" at offset 122880: Success.