VNC Server won't start!

Posted on 2006-04-11
Last Modified: 2010-03-18
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.
Question by:goffer
    LVL 3

    Accepted Solution


    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

    LVL 3

    Expert Comment

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

    # su - billgates
    $ vncpasswd
    $ exit

    # su - stevejobs
    $ vncpasswd
    $ exit

    and ...

    LVL 3

    Expert Comment

    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... ;-))
    LVL 7

    Expert Comment

    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


    Expert Comment

    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?

    Author Comment

    Oops, commented from someone else's account.  Thanks for the help.
    LVL 7

    Expert Comment

    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.


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    ACK Attack 5 53
    Installing Nagwin with mssql backend 9 66
    Lame BIND 9.3 10 47
    Monitor Aliased network interface bandwitch CentOS 4 51
    I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
    Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now