4

I'm trying to upgrade my PostgreSQL 9.4 database to PostgreSQL 9.5 but everytime while running sudo pg_upgradecluster 9.4 main I get this error:

Stopping old cluster...
Disabling connections to the old cluster during upgrade...
Restarting old cluster with restricted connections...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = "en_US.UTF-8",
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Error: The locale requested by the environment is invalid.
Error: Could not create target cluster

But when I run locale I see the LC_ALL is actually set:

LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8

I can remember having the same issue while upgrading from PostgreSQL 9.3 to PostgreSQL 9.4 but that time I fixed this by adding this line to /etc/environment:

LC_ALL=en_US.UTF-8

But this doesn't work anymore.

12

After many attempts to fix this problem, this command finally worked for me:

export LC_CTYPE=en_US.UTF-8 export LC_ALL=en_US.UTF-8
| improve this answer | |
  • LC_CTYPE=en_US.UTF-8 shadows the LC_CTYPE pre-existing in the environment, which appears to be set to UTF-8 according to Perl's error output. Unlike most programs that will just ignore it, postgres' initdb will fail outright on a non-existing locale. The root cause is a rogue LC_CTYPE="UTF-8" somewhere in your init/environment scripts. – Daniel Vérité Jan 21 '16 at 20:30
  • did not work for me. Additionally I am getting this error also => Error: Could not create target cluster – mythicalcoder Aug 7 '17 at 16:20

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.