bash: warning: setlocale: LC_ALL: cannot change locale
Linux
Terminal shows locale warnings on every login — 'cannot change locale (en_US.UTF-8)' — the locale is set but not generated on the system.
Check your exact device first. Codes and procedures vary by model and software version. Back up important files before recovery. Stop if a device is overheating, smells burnt, or has a swollen battery.
CHOOSE HOW YOU WORK
Clear help. Useful detail.
Start with the checks below. Tick a step after you try it, and keep a note of what changed. You can stop as soon as the original task works.
Scope the incident before changing the device.
- Identify
- Distribution and release, kernel version, service or package name, and the complete error.
- Isolate
- User session, service startup, package operation, or filesystem access.
- Capture
- Relevant journal lines, exit status, recent configuration changes, and execution identity. Remove secrets from logs.
Device notes are not sent to the server or AI. Export them before leaving or refreshing this page.
What can cause it?
- Locale set in environment but not generated with locale-gen
- SSH client sending locale that doesn't exist on server
- Minimal server installation without full locale generation
What to try
Work through one step at a timeGenerate the Locale
On Debian/Ubuntu: sudo locale-gen en_US.UTF-8 then sudo update-locale LANG=en_US.UTF-8. On Arch: uncomment en_US.UTF-8 UTF-8 in /etc/locale.gen and run: sudo locale-gen
Set Locale Variables
Add to ~/.bashrc or ~/.profile: export LANG=en_US.UTF-8 and export LC_ALL=en_US.UTF-8. Source the file: source ~/.bashrc
Fix on Remote Server via SSH
If the warning appears when SSH-ing to a server, the client is sending its locale to the server. On the client: edit /etc/ssh/ssh_config and comment out 'SendEnv LANG LC_*'. Or on the server: edit /etc/ssh/sshd_config and comment out 'AcceptEnv LANG LC_*'.
How did it go?
Test the original task again. A completed checklist doesn’t by itself mean the problem is fixed.
Ask the assistant about this errorIf the error comes back
Record the full error, your exact model, software version, and the steps you tried. Share these with the manufacturer or a qualified technician. A repeated code needs a diagnosis, especially if it involves storage, heat, or power.
Find the instructions for your model
Linux official supportThis is a general support link. This reference guide has not been checked against a model-specific source in this update.