Fixing locale and setlocale LC issues in CentOS and RHEL

Locale and setlocale LC error messages

You may receive the following errors when logging in to your CentOS or Red Hat Enterprise Linux (RHEL) system via SSH or at the console:

When running the locale command, you may see these additional errors:

These errors are caused by the system language being set to an unrecognized locale.

Check the /etc/sysconfig/i18n file to see what the system language is set to:

The LANG variable in the /etc/sysconfig/i18n file needs to be set to a valid locale – in some cases, LANG is set to “us” which is not recognized by setlocale, leading to the previously listed errors.
Run the following command to find the valid locales on your system, and compare that to the LANG variable in the /etc/sysconfig/i18n file.

Change your system language to a valid entry as provided by the locale -a command.

Edit the /etc/sysconfig/i18n file:

Change LANG to a valid locale, such as en_US.UTF-8:

Reload the i18n file:

Check the system locale variable, which should now be the same as what you entered in /etc/sysconfig/i18n:

Additional troubleshooting

Issuing the locale command at the console will show you what that current console language is set to:

The following sample output from the locale command shows the system LANG is set to “us,” which is the cause of the error messages. Follow the directions above to change “us” to “en_US.UTF-8” as detailed above.


  1. Hi there,
    Steve first class you have just sorted the language problem I had with a Dedibox server. Much appreciated.
    Stevie Shaw

  2. $ cat /etc/locale.conf
    $ locale -a
    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_COLLATE to default locale: No such file or directory

Leave a Reply

Your email address will not be published.