VNC Server won't start!

I am trying to get VNC to work on my Redhat 9 machine.  At command line I type /home/username/.vnc/xstartup and I receive
(gnome-session:3965): Gtk - WARNING **: cannot open display:

I am receiving this error after I changed the .vnc/xstartup from 'exec /etc/X11/xinit/xinitrc' to 'exec gnome-session'  

Before I chaned xstartup I received
xrdb: Can't open display ''
xrdb: Can't open display ''
xmodmap: unable to open display ''
/usr/X11R6/bin/xmibind: can't open display ''

(gnome-session:3972): Gtk - WARNING**: cannot open display:

Can someone please help!!

I can get VNC to start and run great when I'm logged in as a user at the local machine and type /usr/bin/vncserver.  But I need to have this run from boot and stay running all the time without having access to the console.
Who is Participating?

1. Add the username whom you which to run vnc
edit /etc/sysconfig/vncservers, example

2. To make sure everytime, when you boot up, the vncserver runs
# chkconfig  vncserver  on

3. Assign vnc password for user billgates
# su -  billgates
$ vncpasswd
$ exit

4. To restart vncserver  
# service  vncserver  restart

4. Test it
# vncviewer

To allow more users, edit
VNCSERVERS="1:billgates   2:stevejobs  3:linus"

# su - billgates
$ vncpasswd
$ exit

# su - stevejobs
$ vncpasswd
$ exit

and ...

I found the vnc startup had some quirks -- it wasn't painless when I did it on fedora3 (I have to check why).

Its a good idea to see if the vnc servers are running after you run the start script....i.e.

ps -aux | grep Xvnc
pgrep Xvnc

It took me several hours of playing around with what SHOULD have been a simple process to get it
working right....I'll check later to see what I modified (it may have been operator error... ;-))
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

xstartup won't start vnc, that file is used to initialize your session

Also, use the full path to gnome-session
eg: exec /usr/X11R6/bin/gnome-session

(adjust to suit your environment)

now this probably is not a problem, but
  chkconfig --list xfs

if it comes back *off* for all runlevels, do a
  chkconfig xfs on
  service xfs start

follow kiitii's instructions to get each instance configured


(use your user name on the system)
now again:
[~] chkconfig --list vncserver
vncserver             0:off   1:off   2:off   3:off   4:off   5:off   6:off
[~] chkconfig vncserver on
[~] chkconfig --list vncserver
vncserver             0:off   1:off   2:off   3:on   4:on   5:on   6:off

Okay, apparently all I had to do was the chkconfig vncserver on.  That seems to have done the trick.  I had already set the vnc passwd and set the /etc/sysconfig/vncserver as VNCSERVER="1:user", but when I was trying to just run the command I got those errors.  But apparently using chkconfig vncserver on works, does that do something different?
gofferAuthor Commented:
Oops, commented from someone else's account.  Thanks for the help.
look in your /etc/rc1.d/* /etc/rc5.d/* etc

Those soft links are links to /etc/init.d

/etc/rc5.d/S95vncserver --> /etc/init.d/vncserver
/etc/rc6.d/K35vncserver --> /etc/init.d/vncserver

Now look at the top few lines of /etc/init.d/vncserver:
# chkconfig: - 91 35

Now init *only* looks in the rcnn.d folder for lists of programs to stop and start, so we softlink them all to scripts
that take a stop or start command.  The files are numbered so that the correct sequence is maintained
(eg: useless to start a web server BEFORE network services are up)

Now and administrator's job is to make sure that these softlinks are created or changed to suit whichever services need to be run for each runlevel.
chkconfig just automates that task

Simple example
service start vncserver [vnc is now running]
chkconfig --del vncserver
ls /etc/rc3.d/
ls /etc/rc6.d/
note the soft link is gone

chkconfig --add vncserver
ls /etc/rc3.d/
ls /etc/rc6.d/
Presto chango its back

chkconfig --list vncserver
vncserver       0:off   1:off   2:off   3:off   4:off   5:off   6:off

chkconfig vncserver on
vncserver       0:off   1:off   2:on    3:on    4:on    5:on    6:off
ls /etc/rc3.d/
ls /etc/rc6.d/
note that K35vncserver is gone and S91vncserver is now present.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.