Fixing the locale issue in a clean DigitalOcean droplet

  • Posted February 21, 2014

I’ve read numerous posts about people having problems with the default locale on a clean Digital Ocean droplet with Ubuntu. This manifests in getting errors like:

bash: warning: setlocale: LC_ALL: cannot change locale (en_US)

There is a quick fix, which is just running

locale-gen en_US

But. Can’t this be fixed in the default Ubuntu image? Apparently en_US is installed as the default locale, but the locale files aren’t generated. Am I thinking too simple? Are there any reasons why this can’t be included in the default image?



a quick fix which btw does not fix it for me…

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

this works for me: <br> <br>edit the file <br>/etc/environment <br> <br>add one line with your LANG, like this <br> <br>LC_ALL=“en_US.UTF-8” <br> <br>save and reboot <br> <br>

Are you sure running the following commands doesn’t fix it? <br><pre>sudo locale-gen en_US.UTF-8 <br>sudo dpkg-reconfigure locales</pre>

export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

Then run

sudo update-locale

Now run


you shouldn’t see any errors.

For a permanent solution, Add the above export commands inside ~/.profile

I have written bash scrip to fix this issue, check it out,

The problem still subsists as of January 2018. The solution for me was to add the following to (in my case) the .zshrc file in ~/.

#fix for locale issues when connecting to ubuntu servers export LANG=“en_US.utf8”
export LANGUAGE=“en_US.utf8” export LC_ALL=“en_US.utf8”

I got this from another post in the community wiki.

It is now 2017 and this problem is still not fixed.

It is now 2016 and this problem is still not fixed. Everytime I have to test something and I spin up a Debian or Ubuntu server I ran into this problem. Until I realized it and then fixed it I wasted so much time that all those proposed speed advantages of DO are gone anyway. Currently it looks like this:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_PAPER = "de_CH.UTF-8",
	LC_ADDRESS = "de_CH.UTF-8",
	LC_NUMERIC = "de_CH.UTF-8",
	LC_TIME = "de_CH.UTF-8",
	LC_NAME = "de_CH.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").

What are those crap entries doing in a fresh droplet?

Please try this

sudo nano /etc/default/locale

and edit the contet to be like that: LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LC_TYPE=en_US.UTF-8

It works for me.

Cheers, Ruslan

@juanluis That works for me as well on One-Click WordPress setup. Cheers.

I just had the same problem on a fresh droplet. The solution worked, however it’s a bit weird that the linux images are not preconfigured correctly with working locale settings.