Re: Fwd: localhost not equal at 127.0.0.1 - Mailing list pgsql-jdbc

From Thomas O'Dowd
Subject Re: Fwd: localhost not equal at 127.0.0.1
Date
Msg-id 20011101093825.Q1341@beast.uwillsee.com
Whole thread Raw
In response to Re: Fwd: localhost not equal at 127.0.0.1  (Barry Lind <barry@xythos.com>)
List pgsql-jdbc
While it might be a problem with the network classes it might be caused
by a machine misconfig still. The network classes might be going to DNS
first where as trying from the command line, its possible that it might
go to the files first. Try the following...

$ cat /etc/hosts

See is localhost in there...

$ nslookup localhost

and

$ nslookup localhost.

both should return an address of 127.0.0.1

If it doesn't then it's probably a DNS issue and an A record should be added.

Try also having a look at the file /etc/nsswitch.conf and see the order
for the hosts entry. It should hit local files first.

Some interesting reading on the subject: http://www.localhost.com/dns.html

Cheers,

Tom.

On Wed, Oct 31, 2001 at 04:14:40PM -0800, Barry Lind wrote:
> Given this information it would appear to be a bug in the java network
> classes on this platform.  All the jdbc code is doing is opening a
> socket connection to localhost via ( connection = new Socket(host,
> port); ).  So for some reason the Java Socket class is thinking
> localhost maps to the wrong IP address.
>
> thanks,
> --Barry
>
>
>
> Stéphane Chomat wrote:
>
> > I work with  Mac Os X (10.1) and postgresql 7.1.3
> > Excuse me but no :
> > steph# ping localhost
> > PING localhost (127.0.0.1): 56 data bytes
> > 64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=1.863 ms
> > 64 bytes from 127.0.0.1: icmp_seq=1 ttl=255 time=0.369 ms
> > 64 bytes from 127.0.0.1: icmp_seq=2 ttl=255 time=0.458 ms
> > 64 bytes from 127.0.0.1: icmp_seq=3 ttl=255 time=0.582 ms
> > 64 bytes from 127.0.0.1: icmp_seq=4 ttl=255 time=0.423 ms
> > 64 bytes from 127.0.0.1: icmp_seq=5 ttl=255 time=0.364 ms
> > 64 bytes from 127.0.0.1: icmp_seq=6 ttl=255 time=0.368 ms
> > 64 bytes from 127.0.0.1: icmp_seq=7 ttl=255 time=0.432 ms
> > 64 bytes from 127.0.0.1: icmp_seq=8 ttl=255 time=0.371 ms
> > 64 bytes from 127.0.0.1: icmp_seq=9 ttl=255 time=0.423 ms
> >
> >
> > --- localhost ping statistics ---
> > 10 packets transmitted, 10 packets received, 0% packet loss
> > round-trip min/avg/max = 0.364/0.565/1.863 ms
> >
> > and more, i can obtain my loca page with two different brosser,
> > (http://localhost/).
> > tanks
> > --steph
> >
> > Début du message réexpédié :
> >
> >> De : Barry Lind <barry@xythos.com>
> >> Date : Mer 31 oct 2001  11:15:13  Europe/Paris
> >> À : Stéphane Chomat <steph_chomat@mac.com>
> >> Cc : pgsql-jdbc@postgresql.org
> >> Objet : Rép : localhost not equal at 127.0.0.1
> >>
> >> 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
> >>
> >>
> >>
> >>
> > Stéphane Chomat
> > 22 rue Le Brix
> > 38100 Grenoble
> > 603-999-478
> > steph_chomat@mac.com
> >
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly

--
Thomas O'Dowd. - Nooping - http://nooper.com
tom@nooper.com - Testing - http://nooper.co.jp/labs

pgsql-jdbc by date:

Previous
From: Ned Wolpert
Date:
Subject: Re: Updates to the driver
Next
From: "Nick Fankhauser"
Date:
Subject: Re: Fwd: localhost not equal at 127.0.0.1