2

I had PostgreSQL 9.3 working fine but when I tried to upgrade to 9.5 I began encountering errors. So I purged Postgres from my system following the first answer of this question.

Then I installed postgres 9.5 using

apt-get install postgresql-9.5 postgresql-contrib-9.5 postgresql-doc-9.5

Everything downloaded fine. These are the logs:

sudo apt-get install postgresql-9.5 postgresql-contrib-9.5 postgresql-doc-9.5


Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libntdb1 libossp-uuid16 python-ntdb
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  postgresql-client-9.5 postgresql-client-common postgresql-common
Suggested packages:
  locales-all libdbd-pg-perl
The following NEW packages will be installed:
  postgresql-9.5 postgresql-client-9.5 postgresql-client-common
  postgresql-common postgresql-contrib-9.5 postgresql-doc-9.5
0 upgraded, 6 newly installed, 0 to remove and 14 not upgraded.
Need to get 1,867 kB/7,685 kB of archives.
After this operation, 40.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg/main postgresql-doc-9.5 all 9.5.3-1.pgdg14.04+1 [1,867 kB]
Fetched 1,867 kB in 15s (118 kB/s)                                             
Preconfiguring packages ...
Selecting previously unselected package postgresql-client-common.
(Reading database ... 219906 files and directories currently installed.)
Preparing to unpack .../postgresql-client-common_174.pgdg14.04+1_all.deb ...
Unpacking postgresql-client-common (174.pgdg14.04+1) ...
Selecting previously unselected package postgresql-client-9.5.
Preparing to unpack .../postgresql-client-9.5_9.5.3-1.pgdg14.04+1_amd64.deb ...
Unpacking postgresql-client-9.5 (9.5.3-1.pgdg14.04+1) ...
Selecting previously unselected package postgresql-common.
Preparing to unpack .../postgresql-common_174.pgdg14.04+1_all.deb ...
Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
Unpacking postgresql-common (174.pgdg14.04+1) ...
Selecting previously unselected package postgresql-9.5.
Preparing to unpack .../postgresql-9.5_9.5.3-1.pgdg14.04+1_amd64.deb ...
Unpacking postgresql-9.5 (9.5.3-1.pgdg14.04+1) ...
Selecting previously unselected package postgresql-contrib-9.5.
Preparing to unpack .../postgresql-contrib-9.5_9.5.3-1.pgdg14.04+1_amd64.deb ...
Unpacking postgresql-contrib-9.5 (9.5.3-1.pgdg14.04+1) ...
Selecting previously unselected package postgresql-doc-9.5.
Preparing to unpack .../postgresql-doc-9.5_9.5.3-1.pgdg14.04+1_all.deb ...
Unpacking postgresql-doc-9.5 (9.5.3-1.pgdg14.04+1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
Processing triggers for doc-base (0.10.5) ...
Processing 1 added doc-base file...
Setting up postgresql-client-common (174.pgdg14.04+1) ...
Setting up postgresql-client-9.5 (9.5.3-1.pgdg14.04+1) ...
update-alternatives: using /usr/share/postgresql/9.5/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up postgresql-common (174.pgdg14.04+1) ...
Adding user postgres to group ssl-cert

Creating config file /etc/postgresql-common/createcluster.conf with new version

Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
  en_us
Removing obsolete dictionary files:
 * No PostgreSQL clusters exist; see "man pg_createcluster"
Setting up postgresql-doc-9.5 (9.5.3-1.pgdg14.04+1) ...
update-alternatives: using /usr/share/postgresql/9.5/man/man3/SPI_connect.3.gz to provide /usr/share/man/man3/SPI_connect.3.gz (SPI_connect.3.gz) in auto mode
Processing triggers for ureadahead (0.100.0-16) ...
Setting up postgresql-9.5 (9.5.3-1.pgdg14.04+1) ...
Creating new cluster 9.5/main ...
  config /etc/postgresql/9.5/main
  data   /var/lib/postgresql/9.5/main
  locale en_IN
  socket /var/run/postgresql
  port   5432
update-alternatives: using /usr/share/postgresql/9.5/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
 * Starting PostgreSQL 9.5 database server                                                                                              [ OK ] 
Setting up postgresql-contrib-9.5 (9.5.3-1.pgdg14.04+1) ...

Now when I tried to run rails command

bundle exec rake db:setup

I got the following error

rake aborted!
PG::ConnectionBad: 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.5433"?

In fact if I try to connect through the UI I get the same error.

This is the same problem I was facing when I tried to upgrade to 9.5 initially. I've been struggling with this for 5 hours. Any help would be amazing.

Thank you so much in advance :)

1 Answer 1

0

Note the port number is 5433 in your error, but the install is using 5432. When a second postgres is installed, it will check for a running installation, look at it's port, and use the next one. This allows you to have the two installations running simultaneously, to allow for checking validation before turning off the old one. You can manually edit the file /etc/postgresql/9.5/main/postgresql.conf and change the port to whatever you want to use. I don't know what rake does, maybe it has a port in a config file too.


Reconfigure/restart rake to make it use the 5432 port, since it is failing on port 5433.

2
  • Hi. The rake command is used in this case to create and migrate the db. It does have a port mentioned but that is also 5432. And the postgres.conf file also has 5432 configured in it. So it should work, right? May 23, 2016 at 15:59
  • But I removed all the postgres installation before installing a new one.
    – Soerendip
    Sep 7, 2018 at 23:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .