PuTTY, CygwinX, and X11 forwarding connection refused

39,249

Solution 1

Ok, I figured out the solution to my own problem.

By default CygwinX no longer listens for tcp connections (Cyg SSH is using Unix sockets to connect). To enable tcp connections "-listen tcp" needs to be added to the command line parameters. In my case I changed the "XWin Server" icon to read:

C:\cygwin64\bin\run.exe --quote /usr/bin/bash.exe -l -c "cd; /usr/bin/startxwin -- -multiwindow -listen tcp"

Solution 2

I had this problem. It was because X-Win wasn't running. If you want X-Win to run on startup go "run" then "shell:startup" and copy the x-win shortcut into that folder.

Solution 3

In my case, the error was similar "putty x11 connection refused". I was logging in via a windows machine into a Ubuntu 16 server via putty (with x11 forwarding enabled).

Tried a whole lot of things from re-generating .Xauthority files to adding magic cookie in using xauth list. However, issue was simply that Xming server wasn't running on my windows machine. Once I started Xming on the host machine (windows) on which I was spawning the putty, login via Putty worked like a charm.

Share:
39,249

Related videos on Youtube

SeeJayEmm
Author by

SeeJayEmm

Updated on September 18, 2022

Comments

  • SeeJayEmm
    SeeJayEmm over 1 year

    I am no longer able to forward X11 using KiTTY/PuTTY to CygwinX.

    I am connecting to an Ubuntu Server 14.10 machine that is correctly configured to allow X11 forwarding. I am able to initiate X11 forwarding using Cygwin xterm and from other linux machines.

    I am using CygwinX [1.7.34(0.285/5/3)] and KiTTY 0.64.0.1 (PuTTY fork, I have also tried PuTTY), on Win7.

    I have verified my display variable and have tried disabling xhost access control in Cygwin xterm.

    $ echo $DISPLAY
    :1
    
    $ xhost +
    access control disabled, clients can connect from any host
    

    My KiTTY/PuTTY is configured to enable X11 forwarding and the correct display is set. I've tried :1 and :1.0.

    KiTTY X11 Config Screenshot

    When I SSH to the server my DISPLAY variable is set and xauth is updated. I have deleted my .Xauthority and recreated it to verify.

    user@server:~$ echo $DISPLAY
    localhost:10.0
    user@server:~$ xauth list
    server/unix:10  MIT-MAGIC-COOKIE-1  3983b2d7f3d5f9f66d9796997771bf82
    

    When I attempt to launch an X11 application I get the following error.

    user@server:~$ xterm
    KiTTY X11 proxy: unable to connect to forwarded X server: Network error: Connection refused
    xterm: Xt error: Can't open display: localhost:10.0
    

    XWin.exe is listening on port 34576 if that matters.

    [XWin.exe]
     TCP    127.0.0.1:34576        0.0.0.0:0              LISTENING
    

    I believe there is a software or configuration issue I am missing as I am seeing this with multiple server and client machines. Any help would be appreciated.

    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' almost 9 years
      @lcd047 No, absolutely now. $DISPLAY on the remote machine should point to localhost. SSH does the forwarding.
    • SeeJayEmm
      SeeJayEmm almost 9 years
      I installed 32 bit Cygwin to eliminate Cygwin64 as a variable. No change. Still receiving the connection refused error.
    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' almost 9 years
      @lcd047 No. Please check your facts. If the X11 forwarding happens, then DISPLAY points to localhost. SSH listens on a TCP port on the remote machine and forwards the packets. If DISPLAY pointed to the local machine, that would indicate that it is not forwarded through SSH, but on a direct TCP connection — in cleartext, and possibly to an IP address that doesn't even have a route.
    • SeeJayEmm
      SeeJayEmm almost 9 years
      So I think I've identified part of the problem. It appears that every time I start CygX is listens on a different (random) port number not the base port of tcp 6000. I haven't figured out the next step though.
    • SeeJayEmm
      SeeJayEmm almost 9 years
      Correction, it is not listening at all.
  • chappjc
    chappjc over 8 years
    This works great for me, thanks! But how can I avoid having to do xhost +localhost (or a safer solution) in a local cygwin terminal everytime I start the X server?
  • chappjc
    chappjc over 8 years
    Well, I added xhost +localhost in startxwin right near the end of the file, inside the last conditional: xhost +localhost fi exit $retval
  • Brian Thomas
    Brian Thomas about 7 years
    what about for putty?
  • SeeJayEmm
    SeeJayEmm about 7 years
    @BrianThomas Can you clarify your question? What about PuTTY? The PuTTY config in my original post was valid. The issue was with CygwinX.
  • Brian Thomas
    Brian Thomas about 7 years
    Well, i was referring to the title, Putty not connecting, the answer is for Cygwin, and not for putty, yet i see a putty screen in the OP. Anyhow i figured it out. For putty, the solution to my problem was to make sure only one Xserver (XMing in my case) was running, and that there was no errors in the log on the startup, and its mandatory to specify the display :10 worked for me. (ok, i can see how this doesnt pertain to your answer, since your the original OP, however, theres other people in here too, this issue can be pretty wide. so hopefuly this is helpful to others.)
  • Jonathan Roberts
    Jonathan Roberts over 3 years
    Can you add more details about why this would solve the problem along with any resources/documentation that would help OP solve their problem?