Forward X11 failed: Network error: Connection refused
Asked Answered
T

14

39

I have a VPS which OS is CentOS6.3. I want to run startx via PuTTY and Xming.

But, it produces this error:

PuTTY X11 proxy: unable to connect to forwarded X server: Network error: Connection refused

The whole condition:

Using username "root".
Authenticating with public key "rsa-key-20150906" from agent
Last login: Thu Jan 21 13:53:40 2016 from 222.222.150.82
[root@mairo ~]# xhost +
PuTTY X11 proxy: unable to connect to forwarded X server: Network error: Connection refused
xhost:  unable to open display "localhost:10.0"
[root@mairo ~]# echo $DISPLAY
localhost:10.0
[root@mairo ~]# gedit
PuTTY X11 proxy: unable to connect to forwarded X server: Network error: Connection refused
(gedit:6287): Gtk-WARNING **: cannot open display: localhost:10.0
[root@mairo ~]#

And here is the Xming log:

Welcome to the Xming X Server
Vendor: Colin Harrison
Release: 6.9.0.31
FreeType2: 2.3.4
Contact: http://sourceforge.net/forum/?group_id=156984

Xming :10 -multiwindow -clipboard 

XdmcpRegisterConnection: newAddress 192.168.139.1
winAdjustVideoModeShadowGDI - Using Windows display depth of 32 bits per pixel
winAllocateFBShadowGDI - Creating DIB with width: 1366 height: 768 depth: 32
winInitVisualsShadowGDI - Masks 00ff0000 0000ff00 000000ff BPRGB 8 d 24 bpp 32
glWinInitVisuals:1596: glWinInitVisuals
glWinInitVisualConfigs:1503: glWinInitVisualConfigs glWinSetVisualConfigs:1581: glWinSetVisualConfigs
init_visuals:1055: init_visuals
null screen fn ReparentWindow
null screen fn RestackWindow
InitQueue - Calling pthread_mutex_init
InitQueue - pthread_mutex_init returned
InitQueue - Calling pthread_cond_init
InitQueue - pthread_cond_init returned
winInitMultiWindowWM - Hello
winInitMultiWindowWM - Calling pthread_mutex_lock ()
winMultiWindowXMsgProc - Hello
winMultiWindowXMsgProc - Calling pthread_mutex_lock ()
glWinScreenProbe:1390: glWinScreenProbe
fixup_visuals:1303: fixup_visuals
init_screen_visuals:1336: init_screen_visuals
(--) 5 mouse buttons found
(--) Setting autorepeat to delay=500, rate=31
(--) winConfigKeyboard - Layout: "00000804" (00000804) 
(EE) Keyboardlayout "Chinese (Simplified) - US Keyboard" (00000804) is unknown
Could not init font path element D:\Program Files (x86)\Xming/fonts/misc/, removing from list!
Could not init font path element D:\Program Files (x86)\Xming/fonts/TTF/, removing from list!
Could not init font path element D:\Program Files (x86)\Xming/fonts/Type1/, removing from list!
Could not init font path element D:\Program Files (x86)\Xming/fonts/75dpi/, removing from list!
Could not init font path element D:\Program Files (x86)\Xming/fonts/100dpi/, removing from list!
Could not init font path element C:\Program Files\Xming\fonts\dejavu, removing from list!
Could not init font path element C:\Program Files\Xming\fonts\cyrillic, removing from list!
Could not init font path element C:\WINDOWS\Fonts, removing from list!
winInitMultiWindowWM - pthread_mutex_lock () returned.
winInitMultiWindowWM - pthread_mutex_unlock () returned.
winInitMultiWindowWM - DISPLAY=127.0.0.1:10.0
winMultiWindowXMsgProc - pthread_mutex_lock () returned.
winMultiWindowXMsgProc - pthread_mutex_unlock () returned.
winMultiWindowXMsgProc - DISPLAY=127.0.0.1:10.0
winProcEstablishConnection - Hello
winInitClipboard ()
winProcEstablishConnection - winInitClipboard returned.
winClipboardProc - Hello
DetectUnicodeSupport - Windows Vista
winClipboardProc - DISPLAY=127.0.0.1:10.0
winInitMultiWindowWM - XOpenDisplay () returned and successfully opened the display.
winMultiWindowXMsgProc - XOpenDisplay () returned and successfully opened the display.
winClipboardProc - XOpenDisplay () returned and successfully opened the display.

Here is my sshd_config on VPS:

#   $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options change a
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# Disable legacy (protocol version 1) support in the server for new
# installations. In future the default will change to require explicit
# activation of protocol 1
Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedKeysCommand none
#AuthorizedKeysCommandRunAs nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes

# GSSAPI options
#GSSAPIAuthentication no
GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no

# Set this to 'yes' to enable PAM authentication, account processing, 
# and session processing. If this is enabled, PAM authentication will 
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
#UsePAM no
UsePAM yes

# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS

#AllowAgentForwarding yes
#AllowTcpForwarding yes
GatewayPorts yes
#X11Forwarding no
X11Forwarding yes
#X11DisplayOffset 10
X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem   sftp    /usr/libexec/openssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#   X11Forwarding no
#   AllowTcpForwarding no
#   ForceCommand cvs server

And I have enabled the X11 forwarding

enter image description here

What's causing the error given above?


New added details

According to @lilydjwg answer, I have filled the "X display location" And then tried again, but it's still wrong:

enter image description here

Using username "root".
Authenticating with public key "rsa-key-20150906" from agent
Last login: Thu Jan 21 22:24:57 2016 from 222.222.150.82
[root@mairo ~]# echo $DISPLAY
localhost:10.0
[root@mairo ~]# gedit
process 6968: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open"/var/lib/dbus/machine-id": No such file or directory
See the manual page for dbus-uuidgen to correct this issue.
  D-Bus not built with -rdynamic so unable to print a backtrace
Aborted
[root@mairo ~]#
Thrombus answered 21/1, 2016 at 19:20 Comment(5)
no, you don't. You can't startx over putty.Mcfarlin
@Mcfarlin No only startx, but when I run gedit, it errors as well.Thrombus
I think your gedit problem is unrelated to your X connection. It fails to find a D-Bus connection, which is normally started with your window manager. Try something basic like 'xclock' and see if that works.Repeater
@Repeater Yes, it works after one minute. But still a warning occures Warning: Missing charsets in String to FontSet conversionThrombus
So your X connection is working; you just need some extra components like the D-Bus daemon. The warnings are probably due to missing fonts or locales. BTW, if 'xclock' takes a minute to start up your X connection will be horrendously slow...Repeater
B
28

PuTTY can't find where your X server is, because you didn't tell it. (ssh on Linux doesn't have this problem because it runs under X so it just uses that one.) Fill in the blank box after "X display location" with your Xming server's address.

Alternatively, try MobaXterm. It has an X server builtin.

Babineaux answered 22/1, 2016 at 3:18 Comment(5)
But what to fill? Fill it localhost:10 ?Thrombus
@Thrombus gedit is using D-Bus so you should forward that too. Actually some applications won't work even when you've forwarded D-Bus, e.g. evince.Babineaux
@lilyjwg So, what should I do? Is there anything like pac that can specify which progress forward D-Bus and which not?Thrombus
@Thrombus no, D-Bus does not use JavaScript. You just need a D-Bus, no matter local or remote.Babineaux
Thanks for using the term xming. It reminded that xterm needs a display server! 🙏Perdure
A
74

Other answers are outdated, or incomplete, or simply don't work.

You need to also specify an X-11 server on the host machine to handle the launch of GUId programs. If the client is a Windows machine install Xming. If the client is a Linux machine install XQuartz.

Now suppose this is Windows connecting to Linux. In order to be able to launch X11 programs as well over putty do the following:

- Launch XMing on Windows client
- Launch Putty
    * Fill in basic options as you know in session category
    * Connection -> SSH -> X11
        -> Enable X11 forwarding
        -> X display location = :0.0
        -> MIT-Magic-Cookie-1
        -> X authority file for local display = point to the Xming.exe executable

Of course the ssh server should have permitted Desktop Sharing "Allow other user to view your desktop".

MobaXterm and other complete remote desktop programs work too.

Aframe answered 15/6, 2017 at 19:42 Comment(6)
As of Dec 2019, this should be the accepted answer.Vietnamese
This works perfectly for me too, please accept this answer instead!Maidamaidan
When running firefox on the remote machine I get [GFX1-]: glxtest: libEGL initialize failed. On the host, I have a blank browser.Alishiaalisia
+1 for the use of Xming as a the local display under Windows. Lots of answers on the web talked about manually setting the DISPLAY env var, probably assuming the user is always under GNU/Linux. Which is not the case.Implacental
After a lot of digging for answers, this one fixed it! Thanks so much! This really needs to be the accepted answer!Blare
Absolute lifesaver, +1 times a milliomHupp
B
28

PuTTY can't find where your X server is, because you didn't tell it. (ssh on Linux doesn't have this problem because it runs under X so it just uses that one.) Fill in the blank box after "X display location" with your Xming server's address.

Alternatively, try MobaXterm. It has an X server builtin.

Babineaux answered 22/1, 2016 at 3:18 Comment(5)
But what to fill? Fill it localhost:10 ?Thrombus
@Thrombus gedit is using D-Bus so you should forward that too. Actually some applications won't work even when you've forwarded D-Bus, e.g. evince.Babineaux
@lilyjwg So, what should I do? Is there anything like pac that can specify which progress forward D-Bus and which not?Thrombus
@Thrombus no, D-Bus does not use JavaScript. You just need a D-Bus, no matter local or remote.Babineaux
Thanks for using the term xming. It reminded that xterm needs a display server! 🙏Perdure
T
2

fill in the "X display location" did not work for me. but install MobaXterm did the job.

Teillo answered 15/11, 2019 at 13:52 Comment(0)
T
1

The D-Bus error can be fixed with dbus-launch :

dbus-launch command
Thrombus answered 22/1, 2016 at 15:47 Comment(0)
I
1

I had the same problem, but it's solved now. Finally, Putty does work with Cigwin-X, and Xming is not an obligatory app for MS-Windows X-server.

Nowadays it's xlaunch, who controls the run of X-window. Certainly, xlaunch.exe must be installed in Cigwin. When run in interactive mode it asks for "extra settings". You should add "-listen tcp" to additional param field, since Cigwin-X does not listen TCP by default.

In order to not repeat these steps, you may save settings to the file. And run xlaunch.exe via its shortcut with modified CLI inside. Something like

C:\cygwin64\bin\xlaunch.exe -run C:\cygwin64\config.xlaunch
Individualize answered 7/4, 2020 at 17:51 Comment(0)
E
0

Do not log in as a root user, try another one with sudo permissions.

Electrotherapeutics answered 10/6, 2019 at 20:22 Comment(3)
I think that's caused by the admin of that server disabled PermitRootLogin in sshd_config. If it has been disabled, you cannot login that server as root. However, from the question above, I have already login as root. So using root is not the cause of X11 forward failure.Thrombus
It does not matter, if PermitRootLogin is enabled it is to connect via SSH to the server, regardless of X11Forwarding. Again, the root user will give you problems, and you should not do it for security, it is not a good habit. I recommend that you use Cygwin / X, it is a little faster and more complete, but not as a root user. I'm doing tests with google-chrome and it works fine (a bit slow), although it gives me some errors (the same as in Xming) of GPU and OpenGL that I can not solve.Maybe it's a Ubuntu problem.Electrotherapeutics
I'm sorry, I thought I was in the stackoverflow in Spanish where I have a lot more reputation and I can comment. I was just trying to help. I have a similar problem, and I think I'd better raise a new question.Electrotherapeutics
B
0

X display location : localhost:0 Worked for me :)

Biddie answered 17/1, 2021 at 9:57 Comment(0)
C
0

Windows 10 - Xming.exe to Linux Debian 10 buster X11

ssh.exe -X does not work but ssh.exe -Y does.

Thanks to the answer of @KeyC0de, I've used PuTTY.exe successfully connected from my local Windows 10 to my remote Linux Debian box, enabling using xterm or other X11 graphical programs.

But failed to launch them via a Windows bare ssh.exe session without PuTTY.exe, even though Xming.exe being installed in Windows 10 local host.

To use bare ssh.exe executable, then using xterm under Linux, I succeeded with this method:

  1. Run Xming.exe as X11 Terminal Server under Windows 10.
  2. set environ variable on Windows DISPLAY="localhost:0"
  3. run ssh.exe -Y [email protected]
  4. Run xterm under Linux.

In PowerShell, we do this:

$env:DISPLAY="localhost:0"
ssh.exe -Y [email protected]

Now we are on linux remote box,

We launch X11 program like this:

$ xterm

That's done.

ssh -Y Enables trusted X11 forwarding. Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls.

See https://man.openbsd.org/ssh .


If you are yet on old Windows command line prompt or in a .bat script, here is your way:

In MS-DOS cmd.exe console, we do this:

SET DISPLAY=localhost:0
ssh.exe -Y [email protected]

Illustration on Windows 10 PowerShell console: enter image description here

generating this X11 widget window on Linux:

enter image description here

Cedrickceevah answered 28/3, 2021 at 19:54 Comment(0)
B
0

For me, this was a simple mistake: Xming was not running. Make sure your Xming process is running in the background, or it won't work. For example, if you restart the computer, and don't have Xming set to run automatically.

Bedroll answered 31/3, 2021 at 19:49 Comment(0)
E
0

PuTTY can't find where your X server is, because you didn't tell it. (ssh on Linux doesn't have this problem because it runs under X so it just uses that one.) Fill in the blank box after "X display location" with your Xming server's address. Alternatively, try MobaXterm. It has an X server builtin.

Enright answered 17/10, 2021 at 3:3 Comment(0)
S
0

Try : export DISPLAY=:0 in the console.

Sixtasixteen answered 30/3, 2022 at 14:58 Comment(0)
M
0

I have the same error, in my case I just set the Display number to 0, then I could launch the xeyes OK.

Middlemost answered 25/6, 2022 at 1:49 Comment(0)
L
0

In my case, xterm works. but not the Firefox. It throws an error. unable to connect to forwarded X server: Network error: Software caused connection abort Error: cannot open display: localhost:11.0

Labelle answered 9/8, 2023 at 6:39 Comment(0)
D
-1

you should install a x server such as XMing. and keep the x server is running. config your putty like this :Connection-Data-SSH-X11-Enable X11 forwarding should be checked. and X display location : localhost:0

Diazole answered 13/12, 2017 at 10:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.