I am a new Apple OS X Mabbook user. I am getting an error which read as follows when I connect to any remote Linux/Unix/BSD server or machine through OS X ssh Terminal app:

ssh user@server1.cyberciti.biz
Last login: Wed Mar 26 08:45:36 2014 from
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

How do I fix this error?

Tutorial details
Difficulty level Easy
Root privileges No
Requirements None
Est. reading time 2m
This warning or error is part of both OpenSSH server and macOS or OS X ssh terminal client issue. It can be fixed using various methods.

Understanding LC_* environment variables

Type the following command on remote server to display of all locales supported by Glibc:

$ locale -a

Next, type the following command to display settings on your local system (OSX/Unix/Linux based desktop):

echo "$LC_CTYPE"

Sample outputs:


The above commands display the country and language names, the character encoding used by the locale. Your local ssh client is sending your LC_* environment variables to remote sshd server. In other words, SSH will try to set every LC_* variable you have set on your local OSX system on the remove server too. Here is an example of such problem:

Fig 01: warning setlocale lc_ctype cannot change locale (utf-8)

Fig 01: warning setlocale lc_ctype cannot change locale (utf-8)

Fixing the LC_CTYPE: cannot change locale (UTF-8) error on Linux/OS X

This can be fixed as follows.

Method #1: If you are using the Terminal app on OS X

If you are using the ‘Terminal’ app then click on

Terminal > Preferences > Select Terminal type such as Basic (default) > Advanced tab

Make sure that the ‘Set locale environment variables on startup’ is unchecked as follows:

Fig.02: Fixing OS X terminal by unsetting 'Set locale environment variables on startup' check box

Fig.02: Fixing OS X terminal by unsetting ‘Set locale environment variables on startup’ check box

Here is another screenshot from MacOS X v10.11.6:
Fig.03: Unsetting 'Set locale environment variables on startup' check box on OS X EI Caption

Fig.03: Unsetting ‘Set locale environment variables on startup’ check box on OS X EI Caption

You must close all ssh session and relaunch Terminal app.

Method #2: Preventing OpenSSH Client from sending the LC_* variables on OS X / Linux / Unix desktop

Edit /etc/ssh/ssh_config or /etc/ssh_config file, enter:

$ sudo vi ~/.ssh/config

Remove or comment out as follows:

#SendEnv LANG LC_*

Save and close the file.

Method #3: Install required locale on the remote server

Finally, you can fix this problem either installing the desired locale using the localedef command, or consider choosing a different locale in locale/remote system:

# localedef -i en_US -f UTF-8 en_US.UTF-8

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 28 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
28 comments… add one
  • Mark May 3, 2014 @ 19:20

    Thank you very much, Nix! This solves my problem! :)

  • Atif May 24, 2014 @ 7:56


    The /etc/ssh_cofig change worked for me too.

    • Gustavo Jul 11, 2014 @ 17:13


    • Leonardo Sep 7, 2014 @ 18:58

      Thank you! This was the unique method that worked for me. (I’m using os x mavericks)

  • Devashish Aug 13, 2014 @ 7:20

    The /etc/ssh_cofig fix worked for me. Thanks!
    It was quick, nice, and easy change.

    In your post, You should change
    sudo vi ~/.ssh/config
    sudo vi /etc/ssh_cofig


    • Leo Mar 3, 2017 @ 8:56

      This is path for ubuntu and macOS:

      sudo vi /etc/ssh/ssh_config

  • ohad Sep 1, 2014 @ 10:00

    Thanks that worked like a charm(Method #1)

  • Ramon Nov 18, 2014 @ 17:40

    Thanks a lot!! (solved with method #1)

  • Andrey Jan 8, 2015 @ 11:16

    Thanks a lot!

  • Zague58 Apr 12, 2015 @ 1:07

    Funcionó con localedef -i en_US -f UTF-8 en_US.UTF-8, ya no se presenta el problema.

  • MacHamster May 3, 2015 @ 9:25

    Just wanted to say thanks.
    Using iTerm2 – but there’s no option to unset locale variable on startup in the GUI, so the /etc/ssh_config edit was the way to go – and worked.

    • Keijro Aug 6, 2015 @ 6:14

      In iTerm2 it is done under Preferences -> Profiles -> Terminal
      Uncheck the box “Set locale variables automatically”

  • Mosh May 27, 2015 @ 1:40

    It works!
    Thank you.

  • kde35 Jul 26, 2015 @ 7:54

    Hi, when I tried the third method, I get the error
    “Can’t open charmap file UTF-8: No such file or directory”. Any idea on how to fix this?

  • bs Jul 29, 2015 @ 17:47


  • dangors Aug 12, 2015 @ 10:58

    Hi thanks very much
    Method #2 worked for me but
    i did
    nano /etc/ssh_config to
    fix my error ; now i don’t have the problem again when i ssh into my remote machine.

  • Omer Sep 14, 2015 @ 11:43

    option 3 worked. Thanks

  • EMM Dec 2, 2015 @ 5:34


  • Peter Evans Dec 7, 2015 @ 21:00

    Thanks, Method #1 did the trick for me.

  • Armando G Mar 16, 2016 @ 12:40

    Thanks man, option #1 works (El Capitan)

  • Manish Jaiswal May 9, 2016 @ 18:25

    It worked thanks

  • Louis Sep 28, 2016 @ 2:13

    It works well. Thanks!

  • Paulo A. Nascimento Oct 23, 2016 @ 13:11

    Hi, thanks for the article.
    I was facing this issue, not always, while connection to an EC2 Linux instance through macOS console app, and that small checkbox made all the difference.

  • jules Jan 4, 2017 @ 13:22

    thanks for the clear explanation! bookmarked the site.

  • carlos bautista Feb 3, 2017 @ 16:38

    Thanks Vivek, this is by far the best explanation to this issue I’ve found

  • Santosh Apr 16, 2017 @ 10:58

    Excellent !! Saved my day !! Worked like charm on my Macbook Pro.

  • Indika Kulatunga Oct 11, 2020 @ 10:11

    First method worked for me. Thanks mate

  • frank chen Feb 18, 2021 @ 6:34

    Method#2 works for me and my location of the file is /etc/ssh/ssh_config.
    Thanks a lot!

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum