pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedConnecting via localhost pg-8.0.3
5+ messages / 2 participants
[nested] [flat]
* Connecting via localhost pg-8.0.3
@ 2005-06-15 02:26 David <dbree@duo-county.com>
2005-06-15 03:22 ` Re: Connecting via localhost pg-8.0.3 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 5+ messages in thread
From: David @ 2005-06-15 02:26 UTC (permalink / raw)
To: pgsql-admin
I'm not sure to what list this question belongs, but here goes.
I've just upgraded from 7.4.7 to 8.0.3. All seems to have upgraded well
but I've stumbled across one thing I don't understand. It now seems
that I have to include host=localhost in the pg_connect params from a
php script, whereas these same scripts without this specification worked
with 7.4.7.
I get the following error if I omit "host=localhost" :
Warning: pg_connect(): Unable to connect to PostgreSQL server: could
not connect to server: ¸^@Hv@' Is the server running locally and
accepting connections on Unix domain socket
"/var/run/postgresql/.s.PGSQL.5432"? in
/home/dlb/public_html/test.php
on line 2
I notice that it appears from the above that without the host
specification, the server name comes across as garbage. Again, adding
the host specification eliminates the error.
In my postgresql.conf file, I have the line:
listen_addresses = '*'
the php manual says that you need the '-i' option, but from the 8.0-
docs, it states that the -i option is deprecated and the above line
takes care of it.
This is no show-stopper, just a matter of editing a few lines in my php
files, but I'm just wondering if it's a config parameter on my part or a
change in postgres' default behavior. My php (4.3.10) hasn't been
upgraded for some time, so it shouldn't be in php.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Connecting via localhost pg-8.0.3
2005-06-15 02:26 Connecting via localhost pg-8.0.3 David <dbree@duo-county.com>
@ 2005-06-15 03:22 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-06-16 02:00 ` Re: Connecting via localhost pg-8.0.3 David <dbree@duo-county.com>
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2005-06-15 03:22 UTC (permalink / raw)
To: David <dbree@duo-county.com>; +Cc: pgsql-admin
David <dbree@duo-county.com> writes:
> I've just upgraded from 7.4.7 to 8.0.3.
On what platform, and how did you build or obtain each of these PG
versions?
> I get the following error if I omit "host=localhost" :
> Warning: pg_connect(): Unable to connect to PostgreSQL server: could
> not connect to server: ¸^@Hv@' Is the server running locally and
> accepting connections on Unix domain socket
> "/var/run/postgresql/.s.PGSQL.5432"? in
> /home/dlb/public_html/test.php
> on line 2
The junk text where a kernel error message ought to be is a known
problem with some older RPM distributions (if running in a non-C
locale) but I thought it was fixed in all known 8.0.3 packagings.
So I'm a tad interested to find where your 8.0.3 came from.
As far as actually solving your problem: it's a good guess that
the problem is a confusion about where the Postgres server socket
lives. The error message shows that the client library is looking
in /var/run/postgresql/, but the normal default for this is /tmp/.
Do you see a socket file at /tmp/.s.PGSQL.5432 ? If so then you
have a libpq.so that came from a different build than the server
came from, and the ultimate answer is to get those two components
in sync.
It could well be that both of the above points are explained if
your PHP is linking to an old version of libpq.so that doesn't
match your PG server.
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Connecting via localhost pg-8.0.3
2005-06-15 02:26 Connecting via localhost pg-8.0.3 David <dbree@duo-county.com>
2005-06-15 03:22 ` Re: Connecting via localhost pg-8.0.3 Tom Lane <tgl@sss.pgh.pa.us>
@ 2005-06-16 02:00 ` David <dbree@duo-county.com>
2005-06-16 04:08 ` Re: Connecting via localhost pg-8.0.3 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 5+ messages in thread
From: David @ 2005-06-16 02:00 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: David <dbree@duo-county.com>; pgsql-admin
On Tue, Jun 14, 2005 at 11:22:34PM -0400, Tom Lane wrote:
> David <dbree@duo-county.com> writes:
> > I've just upgraded from 7.4.7 to 8.0.3.
>
> On what platform, and how did you build or obtain each of these PG
> versions?
Oops - thought I included that but apparently didn't..
Platform is Debian. The packages come from The Debian repositories.
> > I get the following error if I omit "host=localhost" :
>
> > Warning: pg_connect(): Unable to connect to PostgreSQL server: could
> > not connect to server: ¸^@Hv@' Is the server running locally and
> > accepting connections on Unix domain socket
> > "/var/run/postgresql/.s.PGSQL.5432"? in
> > /home/dlb/public_html/test.php
> > on line 2
>
> The junk text where a kernel error message ought to be is a known
> problem with some older RPM distributions (if running in a non-C
> locale) but I thought it was fixed in all known 8.0.3 packagings.
> So I'm a tad interested to find where your 8.0.3 came from.
>
> As far as actually solving your problem: it's a good guess that
> the problem is a confusion about where the Postgres server socket
> lives. The error message shows that the client library is looking
> in /var/run/postgresql/, but the normal default for this is /tmp/.
> Do you see a socket file at /tmp/.s.PGSQL.5432 ? If so then you
> have a libpq.so that came from a different build than the server
> came from, and the ultimate answer is to get those two components
> in sync.
Well, you guessed correctly. It was a configuration problem. By
inserting the line:
unix_socket_directory = '/var/run/postgresql'
into postgresql.conf, it works as expected.
I must confess that I was a bit unclear about the connection parameters.
I thought that (in php) "host=localhost" meant to use sockets, but this
means connect through TCP/IP over lo, correct?
> It could well be that both of the above points are explained if
> your PHP is linking to an old version of libpq.so that doesn't
> match your PG server.
I'd wondered if this could have been it, but apparently all appears to
be satisfactory now.
Thanks for the reply. It got me headed in the right direction.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Connecting via localhost pg-8.0.3
2005-06-15 02:26 Connecting via localhost pg-8.0.3 David <dbree@duo-county.com>
2005-06-15 03:22 ` Re: Connecting via localhost pg-8.0.3 Tom Lane <tgl@sss.pgh.pa.us>
2005-06-16 02:00 ` Re: Connecting via localhost pg-8.0.3 David <dbree@duo-county.com>
@ 2005-06-16 04:08 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-06-16 20:22 ` Re: Connecting via localhost pg-8.0.3 David <dbree@duo-county.com>
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2005-06-16 04:08 UTC (permalink / raw)
To: David <dbree@duo-county.com>; +Cc: pgsql-admin
David <dbree@duo-county.com> writes:
> Well, you guessed correctly. It was a configuration problem. By
> inserting the line:
> unix_socket_directory = '/var/run/postgresql'
> into postgresql.conf, it works as expected.
Well, you've still got an issue here somewhere, because if your server
and client libraries came from the same build then they ought to agree
on this without any help from the config file. AFAIK, Debian hasn't
changed their policy about where to put the socket, so it seems like you
must be using a server that didn't come from Debian.
> I must confess that I was a bit unclear about the connection parameters.
> I thought that (in php) "host=localhost" meant to use sockets, but this
> means connect through TCP/IP over lo, correct?
Correct --- "localhost" is an IP-ism referring to TCP loopback
connections. In the Unix-socket world there is no name for the local
machine at all, since that is the whole universe anyway ... all you
need for that is a filesystem pathname.
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Connecting via localhost pg-8.0.3
2005-06-15 02:26 Connecting via localhost pg-8.0.3 David <dbree@duo-county.com>
2005-06-15 03:22 ` Re: Connecting via localhost pg-8.0.3 Tom Lane <tgl@sss.pgh.pa.us>
2005-06-16 02:00 ` Re: Connecting via localhost pg-8.0.3 David <dbree@duo-county.com>
2005-06-16 04:08 ` Re: Connecting via localhost pg-8.0.3 Tom Lane <tgl@sss.pgh.pa.us>
@ 2005-06-16 20:22 ` David <dbree@duo-county.com>
0 siblings, 0 replies; 5+ messages in thread
From: David @ 2005-06-16 20:22 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-admin
On Thu, Jun 16, 2005 at 12:08:35AM -0400, Tom Lane wrote:
> David <dbree@duo-county.com> writes:
> > Well, you guessed correctly. It was a configuration problem. By
> > inserting the line:
> > unix_socket_directory = '/var/run/postgresql'
> > into postgresql.conf, it works as expected.
>
> Well, you've still got an issue here somewhere, because if your server
> and client libraries came from the same build then they ought to agree
> on this without any help from the config file. AFAIK, Debian hasn't
> changed their policy about where to put the socket, so it seems like you
> must be using a server that didn't come from Debian.
dlb@localhost:~$ apt-cache policy postgresql-8.0
postgresql-8.0:
Installed: 8.0.3-5
Candidate: 8.0.3-5
Version Table:
*** 8.0.3-5 0
90 ftp://ftp.us.debian.org sid/main Packages
100 /var/lib/dpkg/status
There is a bug report at bugs.debian.org/postgresql-8.0 (also in the new
postgresql-common package) relating to the location of the socket. I'd
seen this report before posting my original message, but things didn't
click until I read your reply. Anyway, there was a suggestion by
someone that unix_socket_directory needed to be specified.
I do not know now where where the Debian 7.4 socket was located, as I
had no need to look into that.
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2005-06-16 20:22 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-06-15 02:26 Connecting via localhost pg-8.0.3 David <dbree@duo-county.com>
2005-06-15 03:22 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-06-16 02:00 ` David <dbree@duo-county.com>
2005-06-16 04:08 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-06-16 20:22 ` David <dbree@duo-county.com>
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