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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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... ;-))
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

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.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Networking

From novice to tech pro — start learning today.