Fixing the annoying “perl: warning: Setting locale failed” error message

Fixing the annoying “perl: warning: Setting locale failed” error message

I was getting really annoyed getting these messages while managing my Debian and Ubuntu VPSes

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.utf8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

Turns out the solution is simply to run these commands

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
apt-get install locales
dpkg-reconfigure locales

The export lines above can also be saved into either ~/.profile or ~/.bashrc or ~/.cshrc

  • Alex

    Thank you!

  • Thank you!…..

  • Akula Venky

    Thank you for your help

  • Fred Every


  • fuho

    thanks. I have to Google this every single time 🙂

  • Robert

    Thank you!

  • Sandman

    Thanks you so very Much!

  • sippan

    Great ! Thanks 🙂

  • It works great for me! thanks ! (muchas gracias, desde Chile)

  • hmm

    worked for me.!

  • Anders Jonas

    Thank you so much from Cuba! It really worked for me!

  • Panagiotis

    Thank you!!!!! After visited plenty of sites, only your solution worked!!!!!

  • Long Nguyen

    Perfect! Thank you

  • kofolamaster

    i used to get these warnings from cron jobs after updating from locales to ruby-locale. I had to edit /etc/environment and added LC_ALL=”C”

  • silverdr

    This is the simplest and most straightforward fix to this crying shame of an annoying bug in Debian (how come this hasn’t been taken care of for YEARS now??) – thank you! How did you find it, wizard? If I may ask of course. 😉