31

I have an old project that I'm trying to get back into, but I can't enter postgres. Running sudo -u postgres psql gives me:

Error: No existing local cluster is suitable as a default target. 
Please see man pg_wrapper(1) how to specify one.

I'm wondering if this might be because I upgraded postgres to version 9.4 a few months back. This is my output for dpkg --get-selections |grep postgres:

postgresql                          install
postgresql-9.3                      install
postgresql-9.4                      install
postgresql-client-9.3               install
postgresql-client-9.4               install
postgresql-client-common            install
postgresql-common                   install
postgresql-contrib                  install
postgresql-contrib-9.3              install
postgresql-contrib-9.4              install
postgresql-server-dev-9.3           install

These are my current clusters from pg_lsclusters:

Ver Cluster Port Status Owner    Data directory               Log file
9.4 apps    5434 online postgres /var/lib/postgresql/9.4/apps /var/log/postgresql/postgresql-9.4-apps.log

9.4 main    5433 online postgres /var/lib/postgresql/9.4/main /var/log/postgresql/postgresql-9.4-main.log

What can I do to be able to access postgres again? Googling hasn't been much help.

2
  • Please see man pg_wrapper(1) how to specify one.. So, when you read the documentation.... Commented Jun 30, 2015 at 11:34
  • I also started getting the same warning because I went from only having the postgres-10 cluster installed to having the postgres-10 and postgres-11 clusters installed Commented Mar 15, 2020 at 10:07

3 Answers 3

16

As none of your clusters listens on the default port 5432, psql (which is in fact a link to pg_wrapper) doesn't know which one should be the "default".

You may use psql --cluster 9.4/apps [other arguments] to access the first cluster and psql --cluster 9.4/main [other arguments] for the second one.

Or alternatively define a $PGCLUSTER environment variable to 9.4/apps or 9.4/main

These come from rules #2 and #4 (out of 8) of pg_wrapper manpage.

Sign up to request clarification or add additional context in comments.

1 Comment

or locate postgresql.conf and change the port to 5432 in the file of the preferred version
6

If you don't care what your default cluster is, and just want things to work like they did before, just specify the port you want to connect to with

psql -p 5432

and postgres won't try to be clever for you and use a "cluster", whatever that is.

Comments

5

Just set PGCLUSTER

export PGCLUSTER=9.4/main

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.