I am a newbie here and to the server administration. A couple of days back I have registered a server with Hetzner with Ubuntu 11.04.

I intend to work with PostgreSQL, for which I have installed from source after failing to install using apt-get. The installation as such doesn't fail, but the PostgreSQl service doesn't start automatically or when I try to start it manually. It fails with the following error message when I try to do anything with it:

manager@Ubuntu-1104-natty-32-minimal:~$ sudo su postgres -c psql template1
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"?

This was the error I was getting when I had installed PostgreSQL using apt-get and I re-installed it from source. The following is the output I got when I installed it from source. This confirms that the PostgreSQL is indeed installed.

make -C config install
make[1]: Entering directory `/home/manager/postgresql-9.0.4/config'
/bin/mkdir -p '/usr/local/pgsql/lib/pgxs/config'
/bin/sh ../config/install-sh -c -m 755 ./install-sh '/usr/local/pgsql/lib/pgxs/config/install-sh'
make[1]: Leaving directory `/home/manager/postgresql-9.0.4/config'
PostgreSQL installation complete.

But, doesn't the service starts automatically? It doesn't here:

manager@Ubuntu-1104-natty-32-minimal:~$ ps auxw | grep post
manager   6734  0.0  0.0   4156   868 pts/0    S+   14:10   0:00 grep --color=auto post

This is taking a toll on my patience and confidence. Please help me solve this problem.

5 Answers 5


Answering my own question. This is kinda annoying, the first question on any StackExchange site doesn't go well for me.

I had already done this, but somehow worked this time. Did this:

  1. sudo apt-get update && sudo apt-get upgrade
  2. sudo apt-get purge postgresql*
  3. sudo apt-get -f install
  4. sudo apt-get install postgresql

Works like a charm.

Note: adding the * in the purge command will purge all packages that begin with postgresql

  • 4
    Just want to point out that if you have perl: warning: Setting locale failed when installing postgresql, it could cause the installation fail to create a new cluster, so the postgresql server won't start. Fixing that locale problem and reinstalling postgresql with the above instruction worked for me.
    – Hieu
    Feb 27, 2015 at 10:09
  • That worked like a charm for me! Thank you very much, I now have 9.5 installed when I originally installed 9.3 but wanted to switch. In the switch the install and reinstall didn't work very well. Mar 3, 2016 at 11:14

I too faced this problem with Hetzner and very annoying. Here is how I solved it Tip: Looked at some pg package scripts

sudo apt-get purge postgresql* # ending * is important

sudo apt-get install postgresql

I suspect either Hetzner's 11.04 image is buggy or it's Ubuntu's .deb (unlikely though).


I have not seen this error on launchpad in associtiation with Natty. The same issue has been raised as a bug on launchpad for Hardy and got a fix. So following that logic I would expect it to be a bug and it is probably best practice to file a bug on launchpad.

Looking further into it I found 2 interesting (yet old) topics showing the exact same error that seem worth looking into:

This topic from 2006 is talking about the exact same problem and claims that

sudo /etc/init.d/postgresql-8.1 stop

sudo /etc/init.d/postgresql-8.1 start

psql template1


On ubuntuforums there is a topic from 2008 about the same error and has a status 'solved'. Please have a look at the many suggestions in that topic.


psql is the cli client, it does not start the PostgreSQL server. To start the server, you should use:

/etc/init.d/postgresql start

then you can connect to it using psql.

To have PostgreSQL start on boot, you should do the following:

update-rc.d postgresql enable

You might also take a look at this:



Running Ubuntu 14.04, I was having similar problems and couldn't get it working using the above solutions. In the end I found my answer here.

a) I ran this command aptitude search postgresql|grep ^i in terminal and got the following results back:

i   postgresql                      - object-relational SQL database (supported 
i A postgresql-9.3                  - object-relational SQL database, version 9.
i A postgresql-client-9.3           - front-end programs for PostgreSQL 9.3     
i A postgresql-client-common        - manager for multiple PostgreSQL client ver
i A postgresql-common               - PostgreSQL database-cluster manager

b) Then: sudo aptitude purge postgresql postgresql-9.3 postgresql-common

c) Finally: sudo aptitude install postgresql

Everything now works fine.

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.