0

For reasons I can't totally explain, I had both 9.4 and 9.5 installed, which was giving me a headache as I tried to enable PostGIS, which was only installed for 9.5.

I used Synaptic to uninstall postgresql-9.4, and restarted my server with sudo service postgresql start but now I'm finding that I have a bunch of issues:

PGAdmin can't connect. I'm connecting over localhost on port 5432 -- that wouldn't have changed. The connection error says:

Server doesn't listen
The server doesn't accept connections: the connection library reports
could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

In addtion, psql can't see my old databases, and it doesn't recognize any of the roles that I had set up.

I feel like I'm missing something basic here.

1 Answer 1

0

Since you had 2 instances installed, the first (I guess 9.4) was using the default 5432 port so the 2nd got another port (probably 5433). When you uninstalled the first instance, the 2nd doesn't know anything about it and still uses the 5433 port.

You can use pg_lsclusters to find what instances have been installed, and some more details like whether the are running or not, their ports, their data directories, etc. Example:

ian@jupiter:~$ pg_lsclusters
Ver Cluster Port Status Owner    Data directory                 Log file
9.3 main    5437 online postgres /var/lib/postgresql/9.3/main   /var/log/postgresql/postgresql-9.3-main.log
9.3 test93  5438 down   postgres /var/lib/postgresql/9.3/test93 /var/log/postgresql/postgresql-9.3-test93.log
9.4 main    5435 online postgres /var/lib/postgresql/9.4/main   /var/log/postgresql/postgresql-9.4-main.log
9.5 main    5432 online postgres /var/lib/postgresql/9.5/main   /var/log/postgresql/postgresql-9.5-main.log
9.5 repl    5439 online postgres /var/lib/postgresql/9.5/repl   /var/log/postgresql/postgresql-9.5-repl.log
9.5 stage   5433 online postgres /var/lib/postgresql/9.5/stage  /var/log/postgresql/postgresql-9.5-stage.log
9.6 main    5434 online postgres /var/lib/postgresql/9.6/main   pg_log/postgresql-%Y-%m-%d_%H%M.log
9.6 repl    5440 online postgres /var/lib/postgresql/9.6/repl   /var/log/postgresql/postgresql-9.6-repl.log
10  main    5441 online postgres /var/lib/postgresql/10/main    /var/log/postgresql/postgresql-10-main.log
ian@jupiter:~$ 

So the solution is pretty simple. Tell pgAdmin to connect to port 5433 or whichever port your 9.5 has been setup to listen to.

Alternatively, change the configuration of your 9.5 (second and now only one) instance to use port 5432. You need to edit the postgresql.conf file and restart it.

4
  • This helps, thank you! It is indeed on port 5433. But it still isn't respecting my 9.4 roles. How do I migrate those?
    – Amanda
    Mar 23, 2018 at 21:04
  • Any roles and databases that you had created in the 9.4 instance have to be recreated in the 9.5. Did you take a backup of roles and databases before deleting the old instance? Mar 23, 2018 at 21:08
  • I didn't lose anything I can't live with out, but I'm super unclear on what the proper upgrade path should have been.
    – Amanda
    Mar 23, 2018 at 21:11
  • @Amanda various ways to do this. Read this: postgresql.org/docs/9.5/static/upgrading.html Mar 23, 2018 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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