Centos – “Unable to open display ” “” error on VNC Server

centosgnomevnc

I'm trying to run a GUI for my CentOS 6 server. I've installed VNC, and I have followed this guide through to the end – http://wiki.centos.org/HowTos/VNC-Server

Once the VNC server is started, I try to access it through the command:

vncviewer -via username@xxx.xxx.xxx.xx localhost:1

… just like the guide said. Once this runs, it asks for my password for the account, and then displays this error:

vncviewer: unable to open display ""

I've installed GNOME display as stated in the guide, by using the command:

yum groupinstall Desktop

Any ideas?

Edit:
I'm on the CentOS server in question, which looks like terminal at the moment.

I'm trying to get a GUI display running on it, I've entered the command after starting the server vncviewer -via user@ip localhost:1
but it resulted with the same error:

vncviewer: unable to open display ""

In my /etc/sysconfig/vncservers file, I have:

VNCSERVERS="1:user" 
VNCSERVERARGS[1]="-geometry 800x600 -localhost"

Output of netstat -plunt | grep 5901 :

tcp        0      0 127.0.0.1:5901       0.0.0.0:*    LISTEN      29577/Xvnc

Edit #2:
After installing the new packages and running 'startx', it ran for a while. I then recieved a few errors:

Fatal server error:
(EE) no screens found(EE)
Server terminated with error (1). Closing log file.

It looks like it created a log file of the error.
Forgot to mention: After this process errored, Putty encountered a fatal error, causing a connection abort.

Edit #3: Running the command 'init 5' seems to break my server. Had a 'connection error' after running it. Cannot connect back, going to have to get the admins to restart it from their side.

Best Answer

This is the correct way to install vnc server:

Install the following packages:

yum install pixman pixman-devel libXfont tigervnc-server.x86_64 -y

Edit the file /etc/sysconfig/vncservers and add the following lines:

VNCSERVERS="6:<LOGIN_NAME>"
VNCSERVERARGS[6]="-geometry 1152x864"

In the first line, "6:" means that the vnc server daemon will listen on port 590[6] and will log into the specified user's desktop.

Example:

Having "5:itai" there will make the server listen on port 590[5] and connect to itai's desktop.

Then run in order to make sure vncserver starts with boot:

chkconfig vncserver on

Then, set a password for that user, run it from the user's shell (the user you specified in /etc/sysconfig/vncservers):

/usr/bin/vncpasswd

And restart the daemon:

/etc/init.d/vncserver start

Edit #1:

It seems like you installed only the Desktop packages, as far as I know you will need these as well:

yum -y groupinstall "Desktop" "Desktop Platform" "X Window System" "Fonts"

Then run:

init 5
startx
Related Topic