Putty->Cygwin X11 Forwarding “Can't open display” Error
Recent Cygwin updates have changed its X server to not listen for TCP connections by default. Instead, Cygwin's X uses (the Cygwin implementation of) Unix domain sockets, and PuTTY (as a native Windows program) doesn't know how to use these.
The Cygwin X FAQ and Cygwin mailing lists have more details.
My solution was to take the standard Cygwin shortcut that uses startxwin to launch X:
C:\cygwin\bin\run.exe --quote /usr/bin/bash.exe -l -c "cd; /usr/bin/startxwin"
and replace it with a direct invocation of xinit with my desired options (add -listen tcp
and remove -auth
):
C:\cygwin\bin\run.exe --quote /usr/bin/bash.exe -l -c "cd; /usr/bin/xinit /etc/X11/xinit/startxwinrc -- /usr/bin/XWin :0 -multiwindow -listen tcp"
This is less secure than Cygwin's new defaults; it should only be used on a single-user system, and configuring your firewall to block connections to XWin may be wise.
As an alternative to what Josh Kelley said, you can also edit the startxwin file and add the "-listen tcp" to the default server arguments.
Old: defaultserverargs="-multiwindow"
New: defaultserverargs="-multiwindow -listen tcp"
Also with authentication enabled, I had to point putty to the authentication file created by the startxwin script. Mine was located here: c:\cygwin64\home\USERNAME.Xauthority
Since this file is recreated, you will have to restart putty sessions after you reset your xserver.
For security, you might also only allow connections from localhost, as this is where putty forwards it through.