X11 forwarding request failed on channel 0 Error and Solution

I am a new Linux server user. I need to tunnel X over ssh. I type the following command from OS X Unix terminal to login into far_away_machine (a centos server):

ssh -X -o options -A -p 22 user@centos-far-away-server

But, I am getting the following error on screen:

X11 forwarding request failed on channel 0
Last login: Sun Mar 23 15:58:51 2014 from

How do I fix “X11 forwarding request failed on channel 0” on Linux or Unix-like systems?


Tutorial details
Difficulty level Intermediate
Root privileges Yes
Requirements None
Est. reading time 5m
[/donotprint]You may get an error when you try to display a server managment app or any other X app. You will be able to run a graphical application on server and get applications display (window) on your desktop using X11 forwarding. The fix this issue make sure OpenSSH SSHD is configured as follows

Fixing forwarding request failed on channel 0 on a Linux/Unix based server

Login to your centos-far-away-server, enter:
$ ssh -A -p 22 user@centos-far-away-server
Edit /etc/ssh/sshd_config file, enter:
$ sudo vi /etc/ssh/sshd_config
Set the following two options:

X11Forwarding yes
X11UseLocalhost no

Save and close the file. Reload the sshd, enter:
$ sudo /etc/init.d/sshd reload
Sample outputs:

Reloading sshd:                                            [  OK  ]

Install X authority file utility

You need to install xauth tool using yum command:
$ sudo yum install xauth
Sample outputs:

Loaded plugins: downloadonly, fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: mirrors.tummy.com
 * epel: mirror.steadfast.net
 * extras: centos-mirror.jchost.net
 * updates: centos.hostingxtreme.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package xorg-x11-xauth.x86_64 1:1.0.2-7.1.el6 will be installed
--> Processing Dependency: libXmuu.so.1()(64bit) for package: 1:xorg-x11-xauth-1.0.2-7.1.el6.x86_64
--> Running transaction check
---> Package libXmu.x86_64 0:1.1.1-2.el6 will be installed
--> Processing Dependency: libXt.so.6()(64bit) for package: libXmu-1.1.1-2.el6.x86_64
--> Running transaction check
---> Package libXt.x86_64 0:1.1.3-1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
 Package                      Arch                 Version                        Repository          Size
 xorg-x11-xauth               x86_64               1:1.0.2-7.1.el6                base                35 k
Installing for dependencies:
 libXmu                       x86_64               1.1.1-2.el6                    base                66 k
 libXt                        x86_64               1.1.3-1.el6                    base               184 k
Transaction Summary
Install       3 Package(s)
Total download size: 285 k
Installed size: 681 k
Is this ok [y/N]: y
Downloading Packages:
(1/3): libXmu-1.1.1-2.el6.x86_64.rpm                                                |  66 kB     00:00     
(2/3): libXt-1.1.3-1.el6.x86_64.rpm                                                 | 184 kB     00:00     
(3/3): xorg-x11-xauth-1.0.2-7.1.el6.x86_64.rpm                                      |  35 kB     00:00     
Total                                                                      1.2 MB/s | 285 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : libXt-1.1.3-1.el6.x86_64                                                                1/3 
  Installing : libXmu-1.1.1-2.el6.x86_64                                                               2/3 
  Installing : 1:xorg-x11-xauth-1.0.2-7.1.el6.x86_64                                                   3/3 
  Verifying  : libXmu-1.1.1-2.el6.x86_64                                                               1/3 
  Verifying  : libXt-1.1.3-1.el6.x86_64                                                                2/3 
  Verifying  : 1:xorg-x11-xauth-1.0.2-7.1.el6.x86_64                                                   3/3 
  xorg-x11-xauth.x86_64 1:1.0.2-7.1.el6                                                                    
Dependency Installed:
  libXmu.x86_64 0:1.1.1-2.el6                          libXt.x86_64 0:1.1.3-1.el6                         

Try ssh command as follows:
$ ssh -X -o options -A -p 22 user@centos-far-away-server
Sample outputs:

Last login: Sun Mar 23 16:25:09 2014 from
/usr/bin/xauth:  creating new authority file /home/vivek/.Xauthority

Once you got ~/.Xauthority file, you can run X apps as follows over ssh:
$ xeyes &
$ my-cool-raid-app-manager &

Tip: Finding issues with X over ssh

If you still need hints, run ssh command as follows to debug problems:
$ ssh -v user@server-name-here

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

🐧 11 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
11 comments… add one
  • Jeff Silverman Jul 16, 2014 @ 19:06

    This is really good. One minor detail: the yum install xauth command should be run on the centos-far-away-server .

  • Caesar Aug 9, 2014 @ 21:33

    X11UseLocalhost no

    Looking at the sshd_config manpage, I don’t think you want to do that.

    • Paul Sep 4, 2014 @ 17:30

      Why not?

    • monr4 Oct 13, 2014 @ 14:58

      this solve the problem, but i dont know why, if the man say
      Specifies whether sshd(8) should bind the X11 forwarding server to the loopback address or to the wildcard address. By default, sshd
      binds the forwarding server to the loopback address and sets the hostname part of the DISPLAY environment variable to “localhost”.
      This prevents remote hosts from connecting to the proxy display. However, some older X11 clients may not function with this configu-
      ration. X11UseLocalhost may be set to “no” to specify that the forwarding server should be bound to the wildcard address. The argu-
      ment must be “yes” or “no”. The default is “yes”.

      • David Ramirez May 11, 2015 @ 15:35

        Strangely this
        X11UseLocalhost no
        made things work on a remote CentOS 7 machine., that was throwing the error: “no display specified”.

  • MAX Apr 30, 2015 @ 10:55

    I can contribute a real weird cause for this problem in my case:
    On my server I didn’t have syslog installed. So I got
    X11Forwarding working, but there has been no out-
    put when X11UseLocalhost had been set to no.

  • Mauricio Jun 16, 2015 @ 5:59

    Thank you so much.

    I only needed to add this line to the ssh conf file:
    ‘X11UseLocalhost no’

    Now it works!


  • Eric Pretorious Sep 26, 2015 @ 1:14

    Thanks for sharing, Vivek: This worked *almost* perfectly for me. The only change that needs to be made AFAICT: The xauth package has been superseded by the xorg-x11-xauth package.

    Eric P.

  • Larry Dec 7, 2016 @ 14:44

    There’s another issue that can cause this problem. It has to do with IPV4 and IPV6 configuration on the peer hosts. I’ve found that adding this line to sshd_config solves the problem:

    AddressFamily inet

    • Michael Aug 15, 2017 @ 19:38

      This AdressFamily inet (was default ‘any’ before i changed it) did the trick for me. I still wanted Localhost yes as my client did not like getting the display set to the ip # instead of ‘localhost’. Thanks all of you.

  • Ron Jan 20, 2017 @ 4:21

    This worked for me on Ubuntu 14.x client and ubuntu 16.x server (modified server as outlined above):
    X11UseLocalhost no

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