I'm trying to set up a PostgreSQL server using the instructions found on here. I installed the package via apt-get install postgresql and now I'm on the step:

sudo -u postgres psql postgres

which gives the error:

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

I'm guessing the server isn't running but I'm not sure how to start it. Any tips would be much appreciated.

UPDATE: Running service postgresql status doesn't output anything, even after sudo service postgresql start.

UPDATE #2: Running ps auxw | grep post doesn't turn up anything either, so I'm guessing the server daemon isn't running.

  • When you ran apt-get install postgresql, did you check that the installation actually was successful? Please report the output of apt-cache policy postgresql postgresql-9.1. – zwets Dec 12 '13 at 6:16

Check what database clusters are currently created:


If there is one, but it's not running, then start it (substituting the version and name):

sudo pg_ctlcluster x.y name start

If there isn't one, create one and have it started:

sudo pg_createcluster --start x.y name

Normally, this should have happened automatically when you install the package. So either something happened during package installation, or the package was already installed and someone had already messed around with the things I show above.


Wanted to add that if anybody encounters this question but the postgresql server will start the service but not the main cluster fails to initialize then there is an error inside your pg_hba.conf file.

I had to delete every entry except the default ones to get the server to boot the service correctly again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.