Re: Cannot connect although server is running

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kai-Martin <kmk(at)familieknaak(dot)de>
Cc: Postgres-Novice Mailinglist <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Cannot connect although server is running
Date: 2009-04-05 21:29:22
Message-ID: 28954.1238966962@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Kai-Martin <kmk(at)familieknaak(dot)de> writes:
> Since about a month I can't connect to my local postgres server
> any more.

> $ psql
> psql: could not connect to server: No such file or directory
> Is the server running locally and accepting
> connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

> However, the server seems to be running fine:

> $ ps aux |grep postgresql
> postgres 11406 0.0 0.2 21812 3960 ? S 06:24 0:00 /usr/lib/
> postgresql/8.1/bin/postmaster -D /var/lib/postgresql/8.1/main -c
> config_file=/etc/postgresql/8.1/main/postgresql.conf

Well, is there a file "/tmp/.s.PGSQL.5432"? If not, does stopping
and restarting the PG server make it come back?

If that does fix it, then the most likely bet is that you have an
over-aggressive /tmp-cleaning script that removed the file despite
its being a live socket file.

If that doesn't fix it, my next bet is that you are using a build
of Postgres that puts the socket file someplace other than /tmp.
I believe the standard Debian packaging of PG does in fact put it
someplace else (somewhere under /var/run if memory serves ---
lsof on the postmaster process should tell you for sure). If that's
the story, then you must be trying to use a copy of psql/libpq
that wasn't built by Debian and is configured to look in /tmp.
You could force the matter by specifying -h /var/run/wherever
to psql, but it's probably best to install a matching set of executables.

Or maybe you've found some creative new way to break it ;-)
but those are the most common explanations for this error message.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Jana Vasseru 2009-04-05 23:46:17 Export
Previous Message Kai-Martin 2009-04-05 21:05:19 Cannot connect although server is running