Error Codes Wiki

Locale Errors — Cannot Set LC_ALL and Character Encoding Issues on Linux

Informationalsystem

About Locale Errors

Fix Linux locale errors including 'cannot set LC_ALL', missing locale, UTF-8 encoding failures, and locale generation issues on servers. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.

Here are the key things to understand: Locales define language, character encoding, date/time format, and number formatting for the system. The 'cannot set LC_ALL' warning appears when the specified locale is not generated on the system. UTF-8 is the recommended encoding for modern Linux systems. SSH connections may forward the client's locale to the server, causing errors if that locale is not available. Minimal Docker containers and cloud server images often lack locale packages. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: Required locale not generated on the system (e.g., en_US.UTF-8 not in /etc/locale.gen). SSH forwarding the client's locale (LC_ALL, LANG) to a server that does not have it installed. Docker container built from minimal base image without locale packages. locale-gen not run after adding a locale to /etc/locale.gen. Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: Check current locale: 'locale' shows all locale settings, 'locale -a' lists available locales. Generate locale on Debian/Ubuntu: 'sudo locale-gen en_US.UTF-8 && sudo update-locale LANG=en_US.UTF-8'. Generate locale on RHEL/CentOS: 'sudo localedef -i en_US -f UTF-8 en_US.UTF-8'. Stop SSH locale forwarding: comment out 'SendEnv LANG LC_*' in /etc/ssh/ssh_config on the client. For Docker: add 'RUN apt-get install -y locales && locale-gen en_US.UTF-8' and 'ENV LANG=en_US.UTF-8' to Dockerfile. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.

This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.

Quick Answer

Why do I get locale warnings when SSH-ing to a server?

Your SSH client forwards local locale settings (LANG, LC_ALL) to the server. If the server does not have those locales installed, you get warnings. Either install the locale on the server or disable SSH locale forwarding.

Overview

Fix Linux locale errors including 'cannot set LC_ALL', missing locale, UTF-8 encoding failures, and locale generation issues on servers.

Key Details

  • Locales define language, character encoding, date/time format, and number formatting for the system
  • The 'cannot set LC_ALL' warning appears when the specified locale is not generated on the system
  • UTF-8 is the recommended encoding for modern Linux systems
  • SSH connections may forward the client's locale to the server, causing errors if that locale is not available
  • Minimal Docker containers and cloud server images often lack locale packages

Common Causes

  • Required locale not generated on the system (e.g., en_US.UTF-8 not in /etc/locale.gen)
  • SSH forwarding the client's locale (LC_ALL, LANG) to a server that does not have it installed
  • Docker container built from minimal base image without locale packages
  • locale-gen not run after adding a locale to /etc/locale.gen

Steps

  1. 1Check current locale: 'locale' shows all locale settings, 'locale -a' lists available locales
  2. 2Generate locale on Debian/Ubuntu: 'sudo locale-gen en_US.UTF-8 && sudo update-locale LANG=en_US.UTF-8'
  3. 3Generate locale on RHEL/CentOS: 'sudo localedef -i en_US -f UTF-8 en_US.UTF-8'
  4. 4Stop SSH locale forwarding: comment out 'SendEnv LANG LC_*' in /etc/ssh/ssh_config on the client
  5. 5For Docker: add 'RUN apt-get install -y locales && locale-gen en_US.UTF-8' and 'ENV LANG=en_US.UTF-8' to Dockerfile

Tags

localelc-allutf-8encodinginternationalization

Related Items

More in System

Frequently Asked Questions

Your SSH client forwards local locale settings (LANG, LC_ALL) to the server. If the server does not have those locales installed, you get warnings. Either install the locale on the server or disable SSH locale forwarding.