pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Keary Suska <hierophant@pcisys.net>
To: Postgres-PHP <pgsql-php@postgresql.org>
To: Frank Bax <fbax@sympatico.ca>
Subject: Re: unable to connect to pgsql server
Date: Mon, 24 May 2004 10:02:03 -0600
Message-ID: <BCD7789B.11230%hierophant@pcisys.net> (raw)
In-Reply-To: <5.2.1.1.0.20040524084521.02b48060@pop6.sympatico.ca>

on 5/24/04 7:37 AM, fbax@sympatico.ca purportedly said:

> I have a working system on OpenBSD 2.9 / PHP 4.0.4pl1 / pgsql 7.1 / phplib 7.4
> I created a new system on OpenBSD 3.5 / PHP 4.3.5RC3 / pgsql 7.3.5 / phplib
> 7.4
> I copied an existing database and php/phplib application to the new box for
> testing, but when I try to access the application webpage, I get the
> following message in apache error log:
> PHP Warning:  pg_connect(): Unable to connect to PostgreSQL server: unknown
> host name: localhost in /php/class/phplib-7.4/db_pgsql.inc on line 51

Usually, this is either because PHP can't resolve localhost, or the Postgres
server can't/isn't responding. Can you use localhost otherwise? E.g.:
    $ telnet localhost
Even if telnetd isn't running, you should get two different messages--one
that indicates the host won't resolve, and the other indicating that the
host isn't responding (if telnetd isn't running). If you cannot use
localhost from the command line you probably have some other configuration
problem. Also check your nsswitch.conf.

If the above works, make sure the postmaster (Postgres server) has enabled
IP connections. First check if Postmaster is listening using netstat. On my
Linux box, I would use netstat -lnp (but your options may be different). If
it is, check to make sure you are using the correct port. The default is
5432, so if you don't specify the port in the connect string the default
port will be used.

Another possibility is that something is blocking the connection, like a
firewall.

> # cat /etc/hosts | grep -v ^#
> ::1 localhost
> 127.0.0.1 localhost

If nothing else works, this is a wild guess, but I don't know if PHP has
IPv6 support. Just for the heck of it, you may want to try reversing the
above lines in your hosts file so PHP sees the IPv4 address first.

Best,

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"




view thread (7+ messages)  latest in thread

Message-ID: <BCD7789B.11230%hierophant@pcisys.net>
Permalink:  ../BCD7789B.11230%25hierophant@pcisys.net/
Also on:    postgresql.org/message-id/BCD7789B.11230%hierophant@pcisys.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: hierophant@pcisys.net, fbax@sympatico.ca
  Subject: Re: unable to connect to pgsql server
  In-Reply-To: <BCD7789B.11230%hierophant@pcisys.net>
  References: <5.2.1.1.0.20040524084521.02b48060@pop6.sympatico.ca> <BCD7789B.11230%hierophant@pcisys.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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