Re: unable to connect to pgsql server

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



on 5/24/04 7:37 AM, fbax@xxxxxxxxxxxx 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"



[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux