24

I am on a Windows7 machine and I'm trying to get firefox to open on the centOS machine, but be displayed on my current screen. When typing firefox in terminal, I am getting the following error:

Error: cannot open display: localhost:0.0

To setup the display I used the command

$ export DISPLAY=localhost:0.0

Some site suggested using the following, but it didn't work either:

$ export DISPLAY=:0.0

I am using PuTTY and I have the Enable X11 forwarding check box checked and XMing is running on Windows. Additionally, the sshd_config on centOS file seems to be setup properly as well:

$ cat /etc/ssh/sshd_config |grep -i x11
#X11Forwarding no
X11Forwarding yes
#X11DisplayOffset 10
X11UseLocalhost yes

I've looked over numerous pages and searched StackOverflow as well, but none have managed to help me in any way. Thank you in advance.

SaiyanGirl
  • 16,376
  • 11
  • 41
  • 57
  • This question might be more suitable at http://superuser.com/. Besides, in Xming there is `XLaunch` utility, which allows to connect to remote server and launch an application without explicitly using PuTTY and such. Have you tried it? Does it works? – aland Sep 10 '12 at 17:16
  • 2
    try it without setting the DISPLAY variable... you shouldn't actually need that – Scott Sep 10 '12 at 17:33
  • @aland I've looked on the Internet to see what the XLaunch Utility is, I don't know what you mean when you say I should try to launch the application without PuTTY. I just noticed that `XMing` has a `Command Processor`, but I don't know how to use it. - Also, I'm not too sure how to migrate my question. – SaiyanGirl Sep 10 '12 at 17:37
  • @scott654 When I try that, I get the following: `Error: no display specified`. All the suggestions on the Internet say that I should set the display variable to fix that error, but that doesn't do anything for me :( – SaiyanGirl Sep 10 '12 at 17:38
  • @Dana XLaunch is part of XMing distribution, it is a GUI for configuring XMing. By the way, you should not specify DISPLAY variable manually, PuTTY should do that for you. Most likely for remote server you X is not :0.0, but something else (usually :10.0); although your XMing is considering itself to be :0.0, PuTTY does port-forwarding magic to hide that, since :0.0 might be alredy taken by other user or default X or smth. else, so it autimatically finds some available X display number and uses it. – aland Sep 10 '12 at 17:52
  • @Dana Only moderators can migrate questions, you should just flag your question as belonging to SU – aland Sep 10 '12 at 17:58

5 Answers5

16

So, it turns out that X11 wasn't actually installed on the centOS. There didn't seem to be any indication anywhere of it not being installed. I did the following command and now firefox opens:

yum groupinstall 'X Window System' 

Hope this answer will help others that are confused :)

SaiyanGirl
  • 16,376
  • 11
  • 41
  • 57
  • Thank you very much. This solved my problem too. I have been searching all over the net to find this solution. Now I only need gvim to find the fonts and I'm ready to go... – some Oct 20 '12 at 22:20
  • 1
    ... and that was solved by installing the X11 fonts. (in Fedora: `yum search fonts` to get a list of fonts, and then install relevant X11 fonts) – some Oct 20 '12 at 22:29
  • I have the same problem but I dont have ROOT right. Any solution in such case ? – SAAD Aug 03 '14 at 12:56
5

I faced this issue once and was able to resolve it by fixing of my /etc/hosts. It just was unable to resolve localhost name... Details are here: http://itvictories.com/node/6

In fact, there is 99% that error related to /etc/hosts file

X server just unable to resolve localhost and all consequent actions just fails.

Please be sure that you have a record like

127.0.0.1 localhost

in your /etc/hosts file.

Aleks
  • 1,301
  • 2
  • 12
  • 9
3

I had this error message:

Error: Can't open display: localhost:13.0

This fixed it for me:

export DISPLAY="localhost:10.0"

You can use this too:

export DISPLAY="127.0.0.1:10.0"
jturi
  • 1,615
  • 15
  • 11
  • >xauth list This will print the authorization entries for all the displays. Check what number to use. – shubham agarwal Jun 25 '20 at 15:07
  • export DISPLAY="localhost:10.0" this worked for me. Thank you so much. Centos 8 accessing via MobaXTerm v21.2 X11 tab with Dwm <--- i think. – carrabino Aug 08 '21 at 15:22
1

before start make sure of installation:

yum install -y xorg-x11-server-Xorg xorg-x11-xauth xorg-x11-apps
  1. start xming or cygwin
  2. make connection with X11 forwarding (in putty don't forget to set localhost:0.0 for X display location)
  3. edit sshd.cong and restart
     cat /etc/ssh/sshd_config | grep X
                             X11Forwarding yes
                             X11DisplayOffset 10
AddressFamily inet
  1. Without the X11 forwarding, you are subjected to the X11 SECURITY and then you must: authorize the remote server to make a connection with the local X Server using a method (for instance, the xhost command) set the display environment variable to redirect the output to the X server of your local computer. In this example: 192.168.2.223 is the IP of the server 192.168.2.2 is the IP of the local computer where the x server is installed. localhost can also be used.
blablaco@blablaco01 ~
$ xhost 192.168.2.223
192.168.2.223 being added to access control list

blablaco@blablaco01 ~
$ ssh -l root 192.168.2.223
root@192.168.2.223s password:
Last login: Sat May 22 18:59:04 2010 from etcetc
[root@oel5u5 ~]# export DISPLAY=192.168.2.2:0.0
[root@oel5u5 ~]# echo $DISPLAY
192.168.2.2:0.0
[root@oel5u5 ~]# xclock&

Then the xclock application must launch.

Check it on putty or mobaxterm and don't check in remote desktop Manager software. Be careful for user that sudo in.

gawi
  • 2,843
  • 4
  • 29
  • 44
P.Goli
  • 11
  • 3
0

In my case the issue was caused due to mismatch in .Xauthority file. Which initially showed up with "Invalid MIT-MAGIC-COOKIE-1" error and then "Error: cannot open display: :0.0" afterwards

Regenerating the .Xauthorityfile from the user under which I am running the vncserver and resetting the password with a restart of the vnc service and dbus service fixed the issue for me.

user3627034
  • 1,175
  • 8
  • 13