How to solve locale problem in Gnu/Linux (and Docker images)


After setting up a Gnu/Linux Server, Computer or a Docker image, you can get a locale error.

It is because your OS have no default locale and the error output can be like this one:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_PAPER = "az_AZ.UTF-8",
    LC_ADDRESS = "az_AZ.UTF-8",
    LC_MONETARY = "az_AZ.UTF-8",
    LC_NUMERIC = "az_AZ.UTF-8",
    LC_TELEPHONE = "az_AZ.UTF-8",
    LC_TIME = "az_AZ.UTF-8",
    LC_NAME = "az_AZ.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
perl: warning: Setting locale failed.

To solve this issue you can add a default locale to the /etc/default/locale file:


Some times you also need to add this lines to the /etc/environment file.

Or, better way to solve the issue, connect to your server, in colsole run the following command to get the list of locales on your server:


And generate the missing locale:

sudo locale-gen az_AZ.UTF-8

Then reconfigure locales:

sudo dpkg-reconfigure locales

For Docker images, add these lines to your Dockerfile:

RUN export LC_ALL=en_US.UTF-8
RUN export LANG=en_US.UTF-8
RUN locale-gen en_US.UTF-8
Current rating: 1


There are currently no comments

New Comment


required (not published)