Thread: localhost not equal at 127.0.0.1

localhost not equal at 127.0.0.1

From
Stéphane Chomat
Date:
I test the  example corba and i am an exception : "Quelque chose de peu
commun sest produit pour faire ??chouer le gestionnaire. Veuillez
enregistrer cette exception: {0}...". It 's a correct message.
The connection is refused by the server : 'No pg_hba.conf entry for host
217.128.128.146, user user, database dbase' The ip address is not permit
to connect on the server.
But there are a bug : i am not given this ip adresse of my machine. I want
to connect an localhost with 127.0.0.1. When i give this address, it 's ok.
  When i give  no ip address (ex : jdbc:postgresql:dbase ) or i give
localhost (ex : jdbc:postgresql://localhost/dbase), it take the ip address
of the machine)

I think that this is a bug. I propose to add this ligne at the end of the
method parseURL of the file Driver.java.

     String p_PGHOST = urlProps.getProperty("PGHOST");
     if (( p_PGHOST == null) || ( p_PGHOST.equals("localhost"))) {
              urlProps.put("PGHOST", "127.0.0.1");
     }



Stephane Chomat
22 rue Le Brix
38100 Grenoble
603-999-478
steph_chomat@mac.com


Re: localhost not equal at 127.0.0.1

From
"Nick Fankhauser"
Date:
>   When i give  no ip address (ex : jdbc:postgresql:dbase ) or i give
> localhost (ex : jdbc:postgresql://localhost/dbase), it take the
> ip address  of the machine)

using jdbc:postgresql:dbase has always worked for me, so I think something
else is wrong. Either pg_hba.conf needs to be changed or something is
unusual about IP addresses on you computer.

What OS are you using? (There are known problems with this on MacOSX 10.1)

Is there a line in your pg_hba.conf file that is like this?:

host         all         127.0.0.1     255.255.255.255   trust

-NickF


Re: localhost not equal at 127.0.0.1

From
Barry Lind
Date:
I think there is a setup problem with your client.  For some reason
'localhost' is being resolved to an IP address different than 127.0.0.1.
  That is a configuration problem on the computer, not a problem with
the jdbc driver.  If you 'ping localhost' what do you get as the
reported IP address?

The code change you suggest below is not appropriate, because it is
reasonable to expect that other users may desire that localhost resolves
to an IP address other than 127.0.0.1.  So hardcoding this mapping
inside the driver is not correct.

thanks,
--Barry

Stéphane Chomat wrote:

> I test the  example corba and i am an exception : "Quelque chose de peu
> commun sest produit pour faire ??chouer le gestionnaire. Veuillez
> enregistrer cette exception: {0}...". It 's a correct message.
> The connection is refused by the server : 'No pg_hba.conf entry for host
> 217.128.128.146, user user, database dbase' The ip address is not permit
> to connect on the server.
> But there are a bug : i am not given this ip adresse of my machine. I
> want to connect an localhost with 127.0.0.1. When i give this address,
> it 's ok.
>  When i give  no ip address (ex : jdbc:postgresql:dbase ) or i give
> localhost (ex : jdbc:postgresql://localhost/dbase), it take the ip
> address of the machine)
>
> I think that this is a bug. I propose to add this ligne at the end of
> the method parseURL of the file Driver.java.
>
>     String p_PGHOST = urlProps.getProperty("PGHOST");
>     if (( p_PGHOST == null) || ( p_PGHOST.equals("localhost"))) {
>              urlProps.put("PGHOST", "127.0.0.1");
>     }
>
>
>
> Stephane Chomat
> 22 rue Le Brix
> 38100 Grenoble
> 603-999-478
> steph_chomat@mac.com
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>