I have been researching this for some time but I have not been able to find a solution. I do not seem to be able to run X11 applications remotely, on a server running WSL, and have them displayed on my local PC, also running WSL.

I am running WSL on two PCs, let us call them A and B. I have installed VcXsrv on both of them, and can display X11 applications locally, i.e., when I am sitting in front of either one. From A I can ssh into B without any problem, and vice-versa. The .bashrc file in my WSL home directory on both machines includes the line export DISPLAY=localhost:0.0 (I have tried DISPLAY= as well -- it makes no difference).

The problem is, when from A, say, I ssh into B, and launch a graphical application on B, it does not get displayed on the screen of A, but rather it appears on the screen of B (as I verified using Chrome Remote Desktop). The same behavior is observed when ssh-ing from B to A. I have tried to modify the .bashrc file of both machines to

if ! [ $SSH_TTY ] ; then

export DISPLAY=localhost:0.0


but the behavior describes above persists (in this case, the "export DISPLAY" line in .bashrc is ignored on the remote server, and the $DISPLAY variable is set to :0). I have also tried

if ! [ $SSH_TTY ] ; then

export DISPLAY=localhost:0.0


export DISPLAY=localhost:10.0


and this occasionally works, i.e., the application which is running remotely will indeed be displayed on the screen of the local machine. Most of the time, however, I get the error message

X11 connection rejected because of wrong authentication. qt.qpa.screen: QXcbConnection: Could not connect to display localhost:10.0 Could not connect to any X display.

Is there any way out of this? Any help would be greatly appreciated. Thank you in advance.

Additional information:

  1. Windows 10 Home edition, version 1909 (the same problem occurred with 1903 and 18XX).
  2. Same behavior is seen regardless of whether "ssh -X" or "ssh -Y" is used to establish ssh session.
  • 1
    Please edit your question to indicate what version of Windows 10 you are using. Please do not submit a comment. – Ramhound Nov 27 '19 at 2:40
if ! [ $SSH_TTY ] ; then
  export DISPLAY=localhost:0.0

As a rule, it shouldn't be necessary to set the DISPLAY environment variable on the remote system when you forward X. If your SSH client and the ssh server are forwarding X, then the SSH server will initialize the DISPLAY variable for you. By setting DISPLAY yourself, you could be replacing the correct value with an incorrect one. You should remove the code from your .bashrc which sets DISPLAY, or at least avoid overriding DISPLAY when the SSH server sets it for you.

A little background: X clients traditionally connected to X servers through a TCP port. The X server managing the computer's own display normally uses the default TCP port of 6000. As you've indicated, when SSH forwards X, DISPLAY will be set to something like "localhost:10.0", but the number may not be 10. The number part of the DISPLAY setting indicates an offset from port 6000, so "localhost:10.0" refers to an X server on port 6010.

The offset of 10 happens to be the default starting point for the OpenSSH SSH server to use when forwarding X. But it could be configured to use a different starting point, or port 6010 could be in use when you connect to the server. So the SSH server might use a different port, and your forwarded X connection could end up using localhost:11.0, localhost:12.0, or even localhost:100.0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.