Issues exporting X11 display while using SSH from Ubuntu for Windows

9,053

I had the same problem. The solution was to explicitly set the local DISPLAY variable to localhost:0 as opposed to :0.

Local machine:

me@local:~$ echo $DISPLAY
:0
me@local:~$ export DISPLAY=localhost:0
me@local:~$ ssh -X [email protected]

Remote machine:

me@remote:~$ echo $DISPLAY
remote:29.0
me@remote:~$ xeyes

(works)

The error connect /tmp/.X11-unix/X0: No such file or directory certainly results from looking on the local machine for a socket that isn't there, since doing touch /tmp/.X11-unix/X0 before connecting changes the error to connection refused, because it is there, but it is not a valid socket. The explicit localhost:0 seems to allow it to find the socket.

Share:
9,053

Related videos on Youtube

Tom
Author by

Tom

Updated on September 18, 2022

Comments

  • Tom
    Tom over 1 year

    I am using the native Ubuntu terminal in Windows 10, and am trying to export display while using SSH to connect to a remote server. I have XMing installed on the Windows PC, which works on the local Ubuntu after using export DISPLAY=:0. However when I ssh and try to open any display, I get the error below after a long pause:

    ** (gedit:9813): CRITICAL **: log.vala:104: Unable to connect to Zeitgeist: Could not connect: Connection refused
    
    (gedit:18368): dconf-WARNING **: failed to commit changes to dconf: Could not connect: Connection refused
    
    ** (gedit:18368): CRITICAL **: Unable to connect to Zeitgeist's DataSourceRegistry: Could not connect: Connection refused
    

    Does anyone have any ideas to fix this?

    Edit: The way I connect to the remote server is ssh -X username@IP. The server is on Ubuntu 14.04 LTS, and if I use this command from another PC on Ubuntu it works perfectly without needing the export DISPLAY=:0 command.

    However when I ssh using that same command from by Windows 10 subsystem terminal I can connect, but one of two issues occurs. If I do not use export DISPLAY=:0 command, but just call gedit I get the errors below:

    connect /tmp/.X11-unix/X0: No such file or directory
    connect /tmp/.X11-unix/X0: No such file or directory
    
    ** (gedit:10254): WARNING **: Could not open X display
    connect /tmp/.X11-unix/X0: No such file or directory
    connect /tmp/.X11-unix/X0: No such file or directory
    
    (gedit:10254): Gtk-WARNING **: cannot open display: localhost:25.0
    

    Otherwise if I use the export display ccommand first, I get the errors from the original post.

    • smw
      smw over 6 years
      Please edit your question to include exactly how you are ssh'ing to the remote host - including any command line options
    • kmacdonald
      kmacdonald over 6 years
      I believe those messages are not related to the X11 issue at all. If they are, it is not obvious. Please do provide the details, both the ssh command line and the command you execute on the remote system that starts an X11 application. I don't think you need to set DISPLAY if you use the X forwarding feature of the ssh client, but I may be mistaken.
  • Tom
    Tom over 5 years
    Thanks this works perfectly! I added the line "export DISPLAY=localhost:0.0" to my .bashrc and it works locally and over ssh.