Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The installation of postgresql server in Ubuntu 12.04 fails. Its seem to be due to incomplete configuration of postgresql-common package. I purged all packages related to postgresql, tried to reinstall postgresql-common package only. Still error was occuring.

The error is:

$ sudo apt-get install postgresql-common
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/96.5 kB of archives.
After this operation, 442 kB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously unselected package postgresql-common.
(Reading database ... 176855 files and directories currently installed.)
Unpacking postgresql-common (from .../postgresql-common_129ubuntu1_all.deb) ...
Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
Processing triggers for ureadahead ...
Processing triggers for man-db ...
Setting up postgresql-common (129ubuntu1) ...
adduser: The user `postgres' does not exist.
dpkg: error processing postgresql-common (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

Any idea how to overcome/solve this?


  1. I updated and tried again, same error is occuring.
  2. I purged the postgresql related packages and tried to install both postgresql-8.4 and postgresql-9.1, in both cases, it failed due to the dependency to postgresql-common package.
share|improve this question
up vote 3 down vote accepted

The problem was that postgres user was not getting created.(Looks like an error with the package configuration scripts, not sure though) I then created the user manually using:

sudo useradd -r -s /bin/false postgres

The above command is to create a user, without home directory.(Courtesy)

After that I tried to install again, and it succeeded, without any problems.

Some guys at the Ubuntu IRC channel helped me with the solution.


After restart postgresql server was not accessible, so tried to restart postgresql server, and got the following error:

$ sudo service postgresql restart
[sudo] password for username: 
 * Restarting PostgreSQL 8.4 database server                                     
 * The PostgreSQL server failed to start. Please check the log output:
2014-04-03 09:54:22 IST FATAL:  could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied

Solved it by editing the postgresql.conf file. We have to look for the line that begins with that begins unix_socket_directory and change it to read as the following:


Now start the postgresql server using:

sudo service postgresql start

The problem was because

the default directory for lock files in Ubuntu was changed to /var/run/postgresql, which is not world-writable. However, simply changing write permissions on the directory does not work; they are reset when the default init script runs.


Got more info from this link:

But if you are trying a to run an instance of the PostgreSQL server owned by your local user, you need to ensure that the unix socket directory is writable by the user that owns the PostgreSQL server process. Try:


In short:

We had to do that because we created the postgres user manually.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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