pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
postgres 9.0 - unable to bind to localhost.
3+ messages / 3 participants
[nested] [flat]

* postgres 9.0 - unable to bind to localhost.
@ 2012-12-10 08:57 Rajagopalan, Jayashree <Jayashree.Rajagopalan@emc.com>
  2012-12-23 11:38 ` Re: postgres 9.0 - unable to bind to localhost. Strahinja Kustudić <strahinjak@nordeus.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Rajagopalan, Jayashree @ 2012-12-10 08:57 UTC (permalink / raw)
  To: pgsql-admin

Hi all:

Getting this error in the postgres logs:
2012-11-29 09:47:39.335 CST - SessionId:50b7839b.4791 - TransId:0 - LOG:  could not translate host name "localhost", service "5435" to address: Name or service not known
2012-11-29 09:47:39.336 CST - SessionId:50b7839b.4791 - TransId:0 - WARNING:  could not create listen socket for "localhost"
2012-11-29 09:47:39.343 CST - SessionId:50b7839b.4791 - TransId:0 - LOG:  could not resolve "localhost": Name or service not known

Also the netstat command reveals the port(5435) is not bound to 127.0.0.1.
Checked the pg_hba.conf, /etc/hosts, nsswitch.conf, resolv.conf do not see any issues there.

the listen_addresses entry is like this:

listen_addresses = 'localhost,<host_ip>'

The port is bound to the <host_ip> but not to localhost.

How does postgres resolve the local host?

The entry is proper for localhost in /etc/hosts, and nsswitch.conf points hosts to files, dns.

"host localhost" resolves to 127.0.0.1 in command line.

what else to check?

Regards
J

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: postgres 9.0 - unable to bind to localhost.
  2012-12-10 08:57 postgres 9.0 - unable to bind to localhost. Rajagopalan, Jayashree <Jayashree.Rajagopalan@emc.com>
@ 2012-12-23 11:38 ` Strahinja Kustudić <strahinjak@nordeus.com>
  2013-01-30 21:19   ` Re: postgres 9.0 - unable to bind to localhost. Gunnar "Nick" Bluth <gunnar.bluth@pro-open.de>
  0 siblings, 1 reply; 3+ messages in thread

From: Strahinja Kustudić @ 2012-12-23 11:38 UTC (permalink / raw)
  To: Rajagopalan, Jayashree <Jayashree.Rajagopalan@emc.com>; +Cc: pgsql-admin

Sorry for a late reply, but I had the exact same problem and it was a bug
in the Red Hat RPM package upgrade script of the sudo package. This
basically means the user running Postgres cannot resolve hostname
localhost. Have you tried logging in as the user running Postgres and
trying to resolve localhost? In RHEL/Centos you would do this with:

*su - postgres*
*nslookup localhost*

If this returns 127.0.0.1, then something else is a problem, but if it says
the hostname cannot be resolved, then you need to check permissions of
/etc/hosts and /etc/nsswitch.conf, all users should be able to read those
two files. You can just run:

*chmod a+r /etc/hosts*
*chmod a+r /etc/nsswitch.conf*

Another workaround would be to replace 'localhost' in postgresql.conf with
'127.0.0.1'.

Regards,
Strahinja


On Mon, Dec 10, 2012 at 9:57 AM, Rajagopalan, Jayashree <
Jayashree.Rajagopalan@emc.com> wrote:

> Hi all:****
>
> ** **
>
> Getting this error in the postgres logs:****
>
> 2012-11-29 09:47:39.335 CST - SessionId:50b7839b.4791 - TransId:0 - LOG:
> could not translate host name "localhost", service "5435" to address: Name
> or service not known****
>
> 2012-11-29 09:47:39.336 CST - SessionId:50b7839b.4791 - TransId:0 -
> WARNING:  could not create listen socket for "localhost"****
>
> 2012-11-29 09:47:39.343 CST - SessionId:50b7839b.4791 - TransId:0 - LOG:
> could not resolve "localhost": Name or service not known****
>
> ** **
>
> Also the netstat command reveals the port(5435) is not bound to 127.0.0.1.
> Checked the pg_hba.conf, /etc/hosts, nsswitch.conf, resolv.conf do not see
> any issues there.****
>
> ** **
>
> the listen_addresses entry is like this:
>
> listen_addresses = 'localhost,<host_ip>'
>
> The port is bound to the <host_ip> but not to localhost.
>
> How does postgres resolve the local host?
>
> The entry is proper for localhost in /etc/hosts, and nsswitch.conf points
> hosts to files, dns.
>
> "host localhost" resolves to 127.0.0.1 in command line.
>
> what else to check?****
>
> ** **
>
> Regards****
>
> J****
>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: postgres 9.0 - unable to bind to localhost.
  2012-12-10 08:57 postgres 9.0 - unable to bind to localhost. Rajagopalan, Jayashree <Jayashree.Rajagopalan@emc.com>
  2012-12-23 11:38 ` Re: postgres 9.0 - unable to bind to localhost. Strahinja Kustudić <strahinjak@nordeus.com>
@ 2013-01-30 21:19   ` Gunnar "Nick" Bluth <gunnar.bluth@pro-open.de>
  0 siblings, 0 replies; 3+ messages in thread

From: Gunnar \"Nick\" Bluth @ 2013-01-30 21:19 UTC (permalink / raw)
  To: Strahinja Kustudić <strahinjak@nordeus.com>; +Cc: Rajagopalan, Jayashree <Jayashree.Rajagopalan@emc.com>; pgsql-admin

Am 23.12.2012 12:38, schrieb Strahinja Kustudić:
> Sorry for a late reply, but I had the exact same problem and it was a 
> bug in the Red Hat RPM package upgrade script of the sudo package. 
> This basically means the user running Postgres cannot resolve hostname 
> localhost. Have you tried logging in as the user running Postgres and 
> trying to resolve localhost? In RHEL/Centos you would do this with:
>
> *su - postgres*
> *nslookup localhost*
>

A late comment on this one... but I've learnt this lesson the hard way :/
If you want to know what am actual program will get, use "getent hosts 
<hostname/IP>", that will follow the directions in nsswitch.conf and 
also use an nscd, if you're running one.

So, if someone (for whatever reason) once put a line
     1.2.3.4 localhost
in your /etc/hosts, the "nslookup" will return what you'd expect (i.e., 
hopefully ;-), but Postgres will try to open a socket on 1.2.3.4. Bang!

Apart from that:
a) nslookup is deprecated since ages, use "host" or "dig" (well, no, use 
"getent hosts" ;-)
b) I doubt that all DNS possible servers (M$ ones spring to mind...) 
will provide answers to "localhost"

Just my 2p...

-- 
Gunnar "Nick" Bluth
RHCE/SCLA

Mobil   +49 172 8853339
Email: gunnar.bluth@pro-open.de
__________________________________________________________________________
In 1984 mainstream users were choosing VMS over UNIX.  Ten years later
they are choosing Windows over UNIX.  What part of that message aren't you
getting? - Tom Payne

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2013-01-30 21:19 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-12-10 08:57 postgres 9.0 - unable to bind to localhost. Rajagopalan, Jayashree <Jayashree.Rajagopalan@emc.com>
2012-12-23 11:38 ` Strahinja Kustudić <strahinjak@nordeus.com>
2013-01-30 21:19   ` Gunnar "Nick" Bluth <gunnar.bluth@pro-open.de>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox