Postgres with Ubuntu: cannot purge packet

I am trying to run Postgres on a remote server but I can’t run Postgres because I have the following error when I start the server:

root@tradecis2:/home/michael# psql
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 tried to reinstall postgresql by first removing the packages but I have the following error:

E: Sub-process /usr/bin/dpkg returned an error code (1)
root@tradecis2:/home/michael# dpkg -l | grep postgres
pi  postgresql-9.3                      9.3.9-0ubuntu0.14.04             amd64        object-relational SQL database, version 9.3 server
ii  postgresql-client-9.3               9.3.9-0ubuntu0.14.04             amd64        front-end programs for PostgreSQL 9.3
ii  postgresql-client-common            154ubuntu1                       all          manager for multiple PostgreSQL client versions
pF  postgresql-common                   154ubuntu1                       all          PostgreSQL database-cluster manager
root@tradecis2:/home/michael# sudo apt-get purge postgresql-9.3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 11.6 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 93295 files and directories currently installed.)
Removing postgresql-9.3 (9.3.9-0ubuntu0.14.04) ...
/usr/sbin/policy-rc.d: 2: /usr/sbin/policy-rc.d: Syntax error: end of file unexpected (expecting "then")
invoke-rc.d: WARNING: policy-rc.d returned unexpected error status 2, 102 used instead.
invoke-rc.d: policy-rc.d returned error status 102
dpkg: error processing package postgresql-9.3 (--purge):
 subprocess installed pre-removal script returned error exit status 102
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

Source: ubuntu

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.