I'm trying to connect to psql using the below command but receiving message about unset local setting how could one solve it.

 pi@raspberrypi ~/develop/radar $ psql -U postgres
    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
            LANGUAGE = (unset),
            LC_ALL = (unset),
            LC_CTYPE = "UTF-8",
            LANG = "en_GB.UTF-8"
        are supported and installed on your system.
    perl: warning: Falling back to the standard locale ("C").
    psql: FATAL:  Peer authentication failed for user "postgres"
  • /etc/bash.bashrc:export LC_ALL='en_GB.utf8' Remove or edit this line. Commented Feb 10, 2018 at 20:13

5 Answers 5

  • Run raspi-config.
  • Select 4 Internationalisation Options.
  • Within that submenu, complete:
    • I1 Change Locale
    • I2 Change Timezone

However, the warning from perl about locale is not necessarily the reason you are failing authentication.

  • keep receiving errors such as: /usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory /usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory Commented Nov 9, 2015 at 15:06
  • Yeah, I've seen this one repeatedly over at U&L, but for some people nothing seems to work. I'm sure I've solved it this way before (the manual way, starting by editing locale.gen), but I don't think Raspbian should suffer that problem that way in the first place, particularly if you've run raspi-config. Really it shouldn't blow up like this anywhere though, so worth a check.
    – goldilocks
    Commented Nov 9, 2015 at 15:19
  • So the standard Debian method dpkg-reconfigure locales and dpkg-reconfigure tzdata aren't supported on Raspbian or what? Commented Nov 1, 2017 at 22:46

I was having a very similar issue. Here's how I fixed it:

Run sudo nano /etc/default/locale

Change it to include these three lines:


Then reboot the system and it should be updated.


With the new raspbian release Jessie, this can be done easily by just setting the LC_ALL value to C. Here's a link of that solution that i updated on another question. Hope it helps.


Scriptable solution:

sudo -i

echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
locale-gen en_US.UTF-8

echo "LANG=en_US.UTF-8" > /etc/default/locale
update-locale en_US.UTF-8

I met the same problem when using SSH to connect my PI. I noticed that configuration in PI is different from locale settings in my computer.

I change the /etc/default/locale in BOTH pi and computer to the same, and solved.

Hope it helps to others.

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