| From: | Marco Craveiro <marco(dot)craveiro(at)gmail(dot)com> | 
|---|---|
| To: | pgsql-novice(at)postgresql(dot)org | 
| Subject: | Re: Understanding the behaviour of hostname in psql | 
| Date: | 2010-12-05 12:12:51 | 
| Message-ID: | AANLkTinRU9ngCXrpEgHC+DA+7CcNStNsaO_wNRqoHXvt@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-novice | 
thanks for your prompt response Tom.
> Well, a connection to "localhost" will generally go to 127.0.0.1
> (*not* 127.0.1.1 --- that's just a typo from some hand hacking
> of your hosts file, I bet).  A connection to your host name will
> go to whatever the assigned "real" IP is (192.168.0.5 in your
> example).  If you don't have a stable assigned IP because you're
> using DHCP, the best advice would be to always write localhost
> and never bohr in your psql -h switch.
>
> This has nothing much to do with Postgres specifically --- it's a
> generic property of hostname lookup.
nice one, this makes perfect sense. so i cleaned up my hosts file and
my pg_hba.conf
file; also, i've restarted the machine just in case some caching is
happening somewhere.
unfortunately, the result is still not quite right:
    $ psql -h 127.0.0.1 -U marco -w --dbname sanzala
    psql (8.4.5)
    SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
    Type "help" for help.
[marco(at)127(dot)0(dot)0(dot)1:5432 (12:04:40) sanzala ]$ \q
    $ psql -h localhost -U marco -w --dbname sanzala
    psql: fe_sendauth: no password supplied
    $ ping -c 1 localhost
    PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
    64 bytes from localhost.localdomain (127.0.0.1): icmp_req=1 ttl=64
time=0.020 ms
    <snip>
    $ head -n3 /etc/hosts
    192.168.0.5	bohr	# Added by NetworkManager
    127.0.0.1	localhost.localdomain	localhost
    ::1	bohr	localhost6.localdomain6	localhost6
    $ grep /etc/postgresql/8.4/main/pg_hba.conf -B1 -e^host
    # IPv4 local connections:
    host    all         all         127.0.0.1/32          trust
    # IPv6 local connections:
    host    all         all         ::1/128               md5
not quite sure why i still get asked for a password when i login via
localhost...
cheers
-- 
The key to Understanding complicated things is to know what not to
look at, and what not to compute, and what not to think. -- Abelson &
Sussman, SICP
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2010-12-05 17:03:11 | Re: Understanding the behaviour of hostname in psql | 
| Previous Message | Tom Lane | 2010-12-04 21:52:49 | Re: Understanding the behaviour of hostname in psql |