Skip site navigation (1) Skip section navigation (2)

Re: Understanding the behaviour of hostname in psql

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: (view raw or whole thread)
Lists: pgsql-novice
thanks for your prompt response Tom.

> Well, a connection to "localhost" will generally go to
> (*not* --- 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 ( 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 -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 ( 56(84) bytes of data.
    64 bytes from localhost.localdomain ( icmp_req=1 ttl=64
time=0.020 ms

    $ head -n3 /etc/hosts	bohr	# Added by NetworkManager	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          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

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


In response to


pgsql-novice by date

Next:From: Tom LaneDate: 2010-12-05 17:03:11
Subject: Re: Understanding the behaviour of hostname in psql
Previous:From: Tom LaneDate: 2010-12-04 21:52:49
Subject: Re: Understanding the behaviour of hostname in psql

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group