How to Fix Invalid Locale Setting in Ubuntu 14.04 in the Cloud

Ubuntu in the Cloud

Posted on June 4, 2014 in Development

If you use Ubuntu in the cloud, specifically in AWS, you may see this warning message after SSHing into your server:

WARNING! Your environment specifies an invalid locale.
This can affect your user experience significantly, including the
ability to manage packages.

If you than try to install any new packages with apt-get or even restart/reload an existing service, you may get this error message:

perl: warning: Setting locale failed.   
perl: warning: Please check that your locale settings:   
        LANGUAGE = "en_US:en",   
        LC_ALL = (unset),   
        LC_MESSAGES = "en_US.UTF-8",   
        LANG = "en_US.UTF-8"   
    are supported and installed on your system.   
perl: warning: Falling back to the standard locale ("C").   
locale: Cannot set LC_CTYPE to default locale: No such file or directory   
locale: Cannot set LC_MESSAGES to default locale: No such file or directory   
locale: Cannot set LC_ALL to default locale: No such file or directory

The fix is pretty simple. Edit the /etc/environment file and put this line at the end of it:

LC_ALL="en_US.UTF-8"

Save the file, log out and log back into you instance. You should be good. If that doesn’t work, you can try to put these lines in /etc/default/locale instead:

LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"

Enjoyed this post? Share it with others.
Share on email
Email
Share on facebook
Facebook
Share on google
Google
Share on twitter
Twitter

Responses (6)

  1. mojo706
    March 12, 2015 at 10:08 pm · Reply

    Thanks worked on my laptop!

    • pixel.ninja
      March 12, 2015 at 11:43 pm ·

      Yay, that’s awesome! I’m delighted it was helpful.

  2. Dankonino
    June 11, 2015 at 2:02 am · Reply

    Both solutions did not work for me.
    There still this error :
    perl: warning: Setting locale failed.
    perl: warning: Please check that your locale settings:
    LANGUAGE = “en_US:en”,
    LC_ALL = (unset),
    LC_TIME = “de_LI.UTF-8”,
    LC_MONETARY = “de_LI.UTF-8”,
    LC_ADDRESS = “de_LI.UTF-8”,
    LC_TELEPHONE = “de_LI.UTF-8”,
    LC_NAME = “de_LI.UTF-8”,
    LC_MEASUREMENT = “de_LI.UTF-8”,
    LC_IDENTIFICATION = “de_LI.UTF-8”,
    LC_NUMERIC = “de_LI.UTF-8”,
    LC_PAPER = “de_LI.UTF-8”,
    LANG = “en_US.UTF-8”
    are supported and installed on your system.
    perl: warning: Falling back to the standard locale (“C”).
    locale: Cannot set LC_ALL to default locale: No such file or directory

  3. VladVons
    October 21, 2015 at 1:59 pm · Reply

    you can try reinstall locale with apt-get install –reinstall locales
    more read here http://linux-ubuntu.info/en/how-to-change-the-default-locale/

    • pixel.ninja
      October 21, 2015 at 2:56 pm ·

      Thanks for the suggestion, Vlad!

Leave a reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.