perl: warning: Setting locale failed / bash: warning: setlocale: LC_ALL: cannot change locale
Your session asks for a locale (often forwarded by SSH from your Mac/PC) that isn’t generated on the server.
Seen on:
Linux
Meaning
SSH forwards LANG/LC_* variables. If the server doesn’t have that locale (e.g. en_IN.UTF-8 or a macOS default), perl, apt and bash print warnings. Generating the locale or not forwarding it fixes it.
Common causes
- SSH client sends LC_* variables not available on the server
- Locale not generated on a minimal server/container
- LC_ALL set to an invalid value
⚡ Quick fix
- Generate the locale: sudo locale-gen en_US.UTF-8 && sudo update-locale
- Stop forwarding: remove SendEnv LANG LC_* on the client
- Set LANG=C.UTF-8 in containers
Detailed fix by platform
Ubuntu
- bash
sudo locale-gen en_US.UTF-8 sudo update-locale LANG=en_US.UTF-8 locale
Dockerfile
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
How to diagnose
- Requested — locale output / env | grep LC_
- Available — locale -a
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Linux
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026