Postgresql – Why won’t PostgreSQL 9.3 start on Ubuntu

postgresqlpostgresql-9.3

I have successfully installed PostgreSQL 9.3 from the APT repository on 2 VM's running Ubuntu 12.04 and 13.04…however, I cannot get it to install properly on my host machine running Ubuntu 12.04.

The install (this time) seems to have gone ok, but perhaps there is an error I'm not understanding:

* No PostgreSQL clusters exist; see "man pg_createcluster"
Setting up postgresql-9.3 (9.3.0-2.pgdg12.4+1) ...
Creating new cluster 9.3/main ...
  config /etc/postgresql/9.3/main
  data   /var/lib/postgresql/9.3/main
  locale en_US.UTF-8
  port   5432
update-alternatives: using /usr/share/postgresql/9.3/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode.

So I then try to add myself as a PostgreSQL user, but I get this:

createuser: could not connect to database postgres: 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 cannot see PostgreSQL running in system monitor, and there is no file in the /var/run/postgresql/ folder…completely empty.

EDIT: On the VM's, there is a file in /var/run/postgresql/ called 9.3-main.pid

There is nothing on the host machine log file located /var/log/postgresql

So… what's going on here that isn't going on in my VM's? Like I said, the other installations on the VM's, including PostGIS and PGAdmin came in perfect…no idea why this host machine isn't going through…

Best Answer

My locale settings were not properly configured when PostgreSQL was installed. Purging and reinstalling didn't help. I followed the instructions here and that did the trick for me.

Essential parts of the linked information reproduced below:

The problem showed itself in the following manner:

warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
...
are supported and installed on your system.

The first one was very easy to solve by executing:

#dpkg-reconfigure locales

...and choosing the preferred locales.

But after that PostgreSQL still refused to start. This is due to the fact that the installation process tried to create a cluster at installation time but because of the bad locales this wasn't done. So we have to redo this step by executing:

#pg_createcluster 9.3 main --start

(For the 9.3 version of PostgreSQL)

After that step PostgreSQL starts flawlessly via

#/etc/init.d/postgresql start