How to fix apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct! in APT

APTBEGINNERLOWUpdated Mar 7, 2026ยท 281 views

This error occurs when apt-listchanges cannot find a valid locale configuration on your system. Your locale environment variables (LC_* and LANG) are either unset, invalid, or pointing to locales that haven't been generated.

Quick fix

Fixes apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct!

locale
locale -a
  1. Check your current locale configuration
  2. Regenerate locales using dpkg-reconfigure
  3. Or manually enable and generate locales
  4. For SSH-specific issues, check client configuration
apt โ€” error
locale
locale -a
apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct!

What this error means

The error means that apt-listchanges (a tool that displays changes for upgraded packages) tried to format output using your system's locale settings but failed. This happens because either no locales are generated on your system, the locale you're using doesn't exist, or your LANG and LC_* environment variables reference a non-existent locale. While the tools still function, the error prevents proper text formatting and makes the upgrade process uncomfortable.

Typical symptoms

  • apt-listchanges warning appears during apt update or apt upgrade commands
  • Error message shows "Can't set locale; make sure $LC_* and $LANG are correct!"
  • Running locale command shows "Cannot set LC_ALL to default locale" errors
  • SSH connections to the server produce locale-related warnings
  • Perl scripts on the system also complain about locale settings

Common causes

  1. No locales have been generated on the system (most common on minimal/container installations)
  2. Environment variables reference a locale that hasn't been installed (e.g., en_US.UTF-8 is referenced but not in /etc/locale.gen)
  3. Invalid locale codes in LANG or LC_* variables (e.g., en_NL.UTF-8 which doesn't exist)
  4. SSH client forwards unsupported locales from your local machine to a remote server
  5. System upgraded without regenerating locale data after locale installation changes

How to fix "apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct!"

1Check your current locale configuration

First, see what locales are currently set and available:

bash
locale
locale -a

The first command shows your current settings. The second lists all available (generated) locales. If LANG and LC_* variables reference locales not in the list from locale -a, that's your problem.

2Regenerate locales using dpkg-reconfigure

This is the recommended fix on Debian/Ubuntu. Run:

bash
sudo dpkg-reconfigure locales

A dialog will appear. Select at least one locale (en_US.UTF-8 is standard) by pressing SPACE to toggle it. Then press ENTER to confirm. In the next screen, select your preferred default locale. The system will generate the selected locales automatically.

3Or manually enable and generate locales

If dpkg-reconfigure doesn't work, edit the locale generation file directly:

bash
sudo nano /etc/locale.gen

Uncomment (remove the #) from the locale you want (e.g., en_US.UTF-8 or C.UTF-8). Save the file, then run:

bash
sudo locale-gen

Then set it as the default:

bash
sudo update-locale LANG=en_US.UTF-8
4For SSH-specific issues, check client configuration

If you're seeing this error only over SSH, your SSH client may be forwarding unsupported locales. Check your SSH config:

bash
grep -i sendenv ~/.ssh/config

If you see SendEnv LANG LC_*, either remove it or make sure your remote system supports the locales your local machine uses. Alternatively, restart SSH on the server:

bash
sudo systemctl restart ssh
5Verify the fix

After making changes, run apt again:

bash
sudo apt update

The locale warning should be gone. You can also verify with:

bash
locale

Your LANG should now match one of the installed locales from locale -a.

Advanced notes

In container environments (Docker, LXC, Kubernetes), locale generation may require installing the locales package first: apt-get install -y locales. Some minimal images skip this to reduce size. For headless servers where you don't care about locale-specific formatting, you can set LC_ALL=C.UTF-8 to use the minimal locale without generating others, though proper locale generation is preferred. On systems with strict resource constraints, consider installing locales-all instead of configuring individual locales.

Frequently asked questions

What does "apt-listchanges: Can't set locale; make sure $LC_* and $LANG are corre" mean?
The error means that apt-listchanges (a tool that displays changes for upgraded packages) tried to format output using your system's locale settings but failed. This happens because either no locales are generated on your system, the locale you're using doesn't exist, or your LANG and LC_* environment variables reference a non-existent locale. While the tools still function, the error prevents proper text formatting and makes the upgrade process uncomfortable.
How do I fix "apt-listchanges: Can't set locale; make sure $LC_* and $LANG are corre"?
This error occurs when apt-listchanges cannot find a valid locale configuration on your system. Your locale environment variables (LC_* and LANG) are either unset, invalid, or pointing to locales that haven't been generated.
What causes "apt-listchanges: Can't set locale; make sure $LC_* and $LANG are corre"?
No locales have been generated on the system (most common on minimal/container installations) Environment variables reference a locale that hasn't been installed (e.g., en_US.UTF-8 is referenced but not in /etc/locale.gen) Invalid locale codes in LANG or LC_* variables (e.g., en_NL.UTF-8 which doesn't exist)
Is the "apt-listchanges: Can't set locale; make sure $LC_* and $LANG are corre" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading