How to Fix “Failed to set locale, defaulting to C.UTF-8” in CentOS 8

Have you ever encountered the warning/error “Failed to set locale, defaulting to C.UTF-8” in CentOS 8 or RHEL 8? If yes, then this article describes how to fix this error. Note that this article should also work on any operating systems based on RHEL 8.

A locale is a set of basic system parameters that define things such as a user’s language, region and any special variant preferences that the user wants to see in their user interface.

Recommended Read: How to Change or Set System Locales in Linux

On POSIX platforms such as Linux and other Unix-like operating systems, locale identifiers are defined by ISO/IEC 15897. For example, UNITED STATES OF AMERICA (US) English using the UTF-8 encoding is en_US.UTF-8).

The following is a screenshot showing the warning/error when you run the dnf or yum command as shown.

Failed to set locale, defaulting to C.UTF-8

Failed to set locale, defaulting to C.UTF-8

To set system locale, use the localectl command. For example, if you want English – UNITED STATES OF AMERICA (US) using the UTF-8 encoding, run the following command.

# localectl set-locale LANG=en_US.UTF-8

Next, check if the system locale has been set by running the following command.

# localectl
# dnf install @postgresql
Failed to set locale, defaulting to C.UTF-8

Failed to set locale, defaulting to C.UTF-8

Note that even after setting the system locale, the warning persists. This implies that the language packs are missing. To install them, go to the next section.

If a particular language pack is missing on your system, you need to install it to fix the above error. However, you can install all language packs provided by the glibc-all-langpacks package which contains all locales.

# dnf install langpacks-en glibc-all-langpacks -y
Install Language Packs in CentOS 8

Install Language Packs in CentOS 8

Alternatively, if you want to install locales individually, and thus have a smaller package installation footprint on your system, run the following command (replace en with the locale-code you want).

# dnf install glibc-langpack-en

Using the above procedure, we managed to fix the “Failed to set locale, defaulting to C.UTF-8” in CentOS 8 or RHEL 8. Hoping that this worked for you as well, otherwise. give us feedback via the comment form below.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide
The Complete Linux System Administrator Bundle
Become an Ethical Hacker Bonus Bundle

You may also like...

4 Responses

  1. Chamara says:

    Hi, I can’t find DNF. Any solution?

    No command ‘dnf’ found, did you mean:
    Command ‘df’ from package ‘coreutils’ (main)
    Command ‘fnf’ from package ‘confluence’ (universe)
    dnf: command not found

  2. Julian says:

    Thank You. Your solution works.

Got something to say? Join the discussion.

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.