How To Fix “perl: warning: Setting locale failed.” Errors on Linux

I got this error a few days back on one of my Virtual Private Servers,
 Basically, when you ssh into your server you get the following error and if that’s what you are getting and intend to get rid of these, follow the simple steps at the bottom of this post.

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = (unset)
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").

If that’s the issue you are facing, there is a very common fix to this.
 Follow the easy steps.

  • Make/Open the file /etc/environment using any text editor of your choice.
     Example command: nano /etc/environment
  • Add the following in the file
  • LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
  • Save the file, exit the editor, reconnect using SSH to your server.

Hope that helps!


Originally published at Hack4m.