I have installed PostgreSQL 11 but for some reason when I type psql in the terminal I get PostgreSQL version 12 is not installed error

Recently I uninstalled a PostgreSQL server so I think I didn't do it well

How could I get psql command exec version 11 instead of 12



4 Answers 4


I've reproduced your case and here's how I resolved it:

Use sudo apt purge postgresql-12 answering Yes if you want to remove it completely:

  ┌───────────────────────────────────────────────────────────────────┤ Configuring postgresql-11 ├────────────────────────────────────────────────────────────────────┐
  │                                                                                                                                                                    │ 
  │ Removing the PostgreSQL server package will leave existing database clusters intact, i.e. their configuration, data, and log directories will not be removed. On   │ 
  │ purging the package, the directories can optionally be removed.                                                                                                    │ 
  │                                                                                                                                                                    │ 
  │ Remove PostgreSQL directories when package is purged?                                                                                                              │ 
  │                                                                                                                                                                    │ 
  │                                                  <Yes>                                                     <No>                                                    │ 
  │                                                                                                                                                                    │ 

After this:

sudo psql --version
psql (PostgreSQL) 11.7 (Ubuntu 11.7-2.pgdg19.10+1)
  • That's it, Thank you
    – Berre
    Apr 14, 2020 at 17:15
  • 1
    This seems to be generally valid. I first installed postgresql-12 and then updated to postgresql-13, but it was still using the pg_dump from postgresql-12 (so was refusing to dump reload to my postgresql-13 cluster). Purging 12 worked here also. Mar 29, 2021 at 2:26

I had installed postgresql-13 then "rolled back" to postgresql-client-12 after an OS upgrade. I found a zombie /etc/postgresql/13 directory and removed it and I can now successfully execute psql


Just move the /etc/postgresql/12 directory somewhere else and only leave the version that pg_dump is installed on that directory.

I found it out by issuing strace pg_dump|& grep open command


The problem is actually being caused by a postgresql port mapping issue in the config files.

By default, Kali comes with postgres 12 (and postgres 13 as of 2020.3), but OpenVAS needs version 13. Kali configures postgres 12 to port 5532 and assigns a higher port (in this case, 5433) for postgres 13. OpenVAS is still looking for 5432 so sees postgres 12 even if 13 is installed.

remove postgresql 12 if you can...if not

A quick solution is to edit the "port = " lines in the

/etc/postgresql/12/main/postgresql.conf port = 5433


/etc/postgresql/13/main/postgresql.conf port = 5432

basically swap the port values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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