Konrad Podgórski - Web Developer

Personal blog about developing web applications with Symfony, Node JS and Angular JS

Fixing the locale problem in Debian - mirror

Post was originally posted on http://hexample.com/2012/02/05/fixing-locale-problem-debian/

I was using this tutorial for a very long time, it was also linked from my other posts. However in last month I noticed it's no longer available. Full credit for this awesome tutorial goes to Crypto, the original author.

People who aren’t using the default locales (en_US) on their Debian based servers, often see error messages like perl: warning: Setting locale failed or perl: warning: Falling back to the standard locale (“C”). A listing of the complete error message is given in the full article. The error messages appear when installing packages with apt-get or when using some common perl commands like auto completion. On the internet you find a lot of different solutions that may work. This tutorial gives a more comprehensive approach to the matter. This way you understand the error and you are able to fight this annoying error message.

This little tutorial and fix is for everyone who gets following error code.

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_CTYPE = "UTF-8",
        LANG = "en_US"
    are supported and installed on your system.

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

Quick checklist

  1. Check if locales is installed
  2. Check the used/needed locales
  3. Check the available locales
  4. Generate all needed locales
  5. Log out and back in

Full explanation

On the internet you will find fixes that tell you to do dpkg-reconfigure or locales-gen. They are correct, but aren’t enough if you do it brainlessly. What you have to do is first check if the locales package is installed.

apt-get install locales

In most cases it will report that locales is already installed and up to date.

Second, what most how-to’s and fixes forget to mention, it is very important to know which locales are needed by the system.

sudo locale

By running this command, you will get a list of every needed locale. It is important to write down the locales other than en_US. On my system there was an extra locale nl_NL.UTF-8.

Now, you have to check which locale is already present on the system. Do this by running the following listing.

sudo locale -a

Normally you will see some English locales. But your extra locales are probably missing.

You have two options to add those extras. The first one is locale-gen, the second one is dpkg-reconfigure. I advise the latter if it is present on your system. I will discuss the two solutions.


sudo dpkg-reconfigure locales

First you’ll get a menu in which you have to select all needed locales. Select the English ones AND your extras with the space-bar.

In the next window select en_US.UTF-8 as default locale.

After regenerating the locales log out and back in. Your problem is solved!


If for some reason dpkg-reconfigure is not available on your environment or your local user doesn’t have admin privileges, you can always use locale-gen. Use this command and append every extra locale you need.

If you need the nl_NL.UTF-8 locale:

locale-gen nl_NL.UTF-8

Repeat this step for every locale you need. You can check if it was successful by running locale -a. Normally all your generated locales should be listed. Log out and back in to activate the new locales for your session.


I hope this quick fix helped you to fix the annoying missing locale bug. If you find it helpful or have some questions, please leave a message below.

Published on

Find this post helpful? Spread the word, thanks.