can't set locale

Can’t set locale; make sure $LC_* and $LANG are correct! This suddenly appeared on all my servers one day after some updates. All of them were running Debian. And I thought at first there was some bad packages or settings in some of the new updates. Little did I know the problem wasn’t related to Debian or my server at all. But my Laptop. I had also updated MacOS the same day.

Can’t set locale; make sure $LC_* and $LANG are correct!

If you get Can’t set locale; make sure $LC_* and $LANG are correct, is it only when using a particular program. Or is it when you SSH in from another computer? If you get it from SSH, try to see if you get the same error when using terminal locally. If it only appears when using SSH, you probably have the same issue I had. At least it is something with the SSH client.

To fix your SSH client, assuming you are running MacOS, you need to edit the /etc/ssh/ssh_config file. That is where the problem is. If you have an older OS X like Mountain Lion, you will find the file at /etc/ssh_config. What you need to do is remove or comment out this line: SendEnv LANG LC_*

can't set locale

By removing the SendEnv LANG LC_* you stop your client from sending invalid locale information to your server, or computer you SSH into.

Another type of error that can be caused by invalid locale, is various Python script errors. If you ever got this error “UnicodeEncodeError: ‘ascii’ codec can’t encode character …”. You should also try to remove the SendEnv LANG LC_* from ssh_config. Other users have reported that to be the solution to this issue.

Please also read SSH slow login on Debian based systems

Leave a Reply