postgresql cannot connect to server locally

postgresql-9.1, ubuntu-12.04

Solution

It seems that you did not install postgresql successfully. Please follow here:

sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get -y update
sudo apt-get purge postgresql* # ending * is important
sudo apt-get install postgresql libpq-dev

It will fix your problem.

Problem

I've just installed the postgresql 9.1 on one brand new Ubuntu 12.04 LTS server with the following command : sudo apt-get install postgresql libpq-dev The installation proceeded without errors. Basically I should be able to connect to local server, however when I tap the command psql, the following errors appears : 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've searched a lot of posts online, but cannot solve problem (very often, the mentioned directory doesn't exist on my server). Can anyone suggests some solutions ? Thanks !

Original source