Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a very stubborn, well-known locale error on Ubuntu 9.10:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_TIME = "custom.UTF-8",
    LANG = "en_US.UTF-8"

Tried the following:

  • Added LANG=en_US.UTF-8 and LC_ALL=en_US.UTF-8 to /etc/environment
  • Run apt-get install --reinstall locales (error: perl: warning: Falling back to the standard locale ("C"). /usr/bin/mandb: can't set the locale; make sure $LC_* and $LANG are correct)
  • Run sudo dpkg-reconfigure locales. Result: Cannot set LC_ALL to default locale: No such file or directory, and then updates locales all locales including en_US.UTF-8
  • sudo locale-gen updates all locales successfully, including en_US.UTF-8
  • sudo locale-gen un_US en_US.UTF-8 gives no error nor other output
  • In /etc/default/locale it says LANG="en_US.UTF-8"
  • echo $LANG gives en_US.UTF-8
  • /var/lib/locales/supported.d/local says en_US.UTF-8 UTF-8
  • locale -a gives me:

So well... I am pretty much out of options I can think of. Anybody any idea??


share|improve this question
up vote 3 down vote accepted

Had the same problem and found the solution. You have to recreate the custom.UTF-8 locale def (the "custom" file is probably there because you changed the date or time format). Run

sudo localedef -f UTF-8 -i custom custom.UTF-8

Another way to do this is to add the locale to the ones you want dpkg-reconfigure locales to configure for you. On Debian:

echo 'custom.UTF-8 UTF-8' |sudo tee -a /etc/locale.gen
sudo dpkg-reconfigure locales

On Ubuntu:

echo 'custom.UTF-8 UTF-8' |sudo tee -a /var/lib/locales/supported.d/local
sudo dpkg-reconfigure locales

Hope this helps!

share|improve this answer

You could also try to install the locales-all package, to avoid having to generate any locales ever again.

share|improve this answer
Thank you! This is the only thing that worked for me and it's super easy. – eisbaw Jan 19 '12 at 10:38

I solved the same problem on a Ubuntu 10.04 server this way:

root@hostname:~# export LANGUAGE=en_US.UTF-8
root@hostname:~# export LANG=en_US.UTF-8
root@hostname:~# export LC_ALL=en_US.UTF-8
root@hostname:~# locale-gen en_US.UTF-8
root@hostname:~# dpkg-reconfigure locales

Hope this could help.

share|improve this answer

I solved the same problem on a Ubuntu 10.04 server this way:

$ export LANGUAGE=en_US.UTF-8
$ export LANG=en_US.UTF-8
$ export LC_ALL=en_US.UTF-8
$ sudo locale-gen en_US.UTF-8
$ sudo dpkg-reconfigure locales

To make the changes permanent you need to add there variable into /etc/environment

$ sudo vi /etc/environment
share|improve this answer
It would be better to set the locale variables (LANGUAGE, LANG, & LC_ALL) in you local profile or shell .rc file -- while in your environment everyone might be in the same location, speaking the same language, etc. sometimes you have to coexist on a server with people from all over the world. That's why you can set things like this with environment variables :-) – voretaq7 Nov 11 '12 at 2:12

LC_TIME = "custom.UTF-8"

This one looks quite odd, it should be "en_US.UTF-8", not "custom.UTF-8" You should grep /etc to see where it comes from.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.