X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5AE4ED1B888 for ; Mon, 24 May 2004 13:02:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 96227-03 for ; Mon, 24 May 2004 13:02:06 -0300 (ADT) Received: from marsha.pcisys.net (marsha.pcisys.net [216.229.32.146]) by svr1.postgresql.org (Postfix) with ESMTP id 03387D1B183 for ; Mon, 24 May 2004 13:02:05 -0300 (ADT) Received: from [192.168.0.6] (moe.rbe45-127.cos.pcisys.net [216.229.45.127]) (authenticated bits=0) by marsha.pcisys.net (8.12.11/8.12.11) with ESMTP id i4OFxB9F016645; Mon, 24 May 2004 09:59:11 -0600 (MDT) User-Agent: Microsoft-Entourage/10.1.4.030702.0 Date: Mon, 24 May 2004 10:02:03 -0600 Subject: Re: unable to connect to pgsql server From: Keary Suska To: Postgres-PHP , Frank Bax Message-ID: In-Reply-To: <5.2.1.1.0.20040524084521.02b48060@pop6.sympatico.ca> Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200405/48 X-Sequence-Number: 2767 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"