VNC Starting Automatically on Raspberry Pi

Posted: January 12, 2014 by schoolpiclub in General News


We previously posted about how to connect to your Raspberry Pi via an iPad using VNC. See post

The only thing was the VNC did not start automatically when booting up the Raspberry Pi. This weekend I have been configuring my Raspberry Pi so that it started the VNC server automatically. This meant that I can just plug my Raspberry Pi in anywhere at home  – no need to connect to a TV to monitor – and then either use my iPad, Macbook or a PC to remote connect to it to control it.

Once you have set up the ‘tightvncserver’ from our previous post, this is how to config VNC to start automatically.

Start VNC automatically

Create startup file
The first thing you need to do is create the file that will actually start VNC on startup using Terminal directly from the Pi.

Type the following:
sudo nano /etc/init.d/tightvncserver

NOTE: nano is a lightweight editor – the command above will create a new file called tightvncserver in the /etc/init.d directory and open it for editing.
Once you have the file open, paste in the following:

# First configure the user you want to run this under – this will generally be pi, unless you’ve created your own users
export USER=’pi’

eval cd ~$USER

# Check the state of the command – this’ll either be start or stop 

case “$1” in
    # if it’s start, then start vncserver using the details below
    su $USER -c ‘/usr/bin/vncserver :1 -geometry 1280×800 -depth 16 -pixelformat rgb565’
    echo “Starting vncserver for $USER “
    # if it’s stop, then just kill the process
    pkill Xtightvnc
    echo “vncserver stopped”
    echo “Usage: /etc/init.d/vncserver {start|stop}”
    exit 1
exit 0

NOTE: In the file I’ve specified my own resolution with the text -geometry 1280×800 – you can leave this out of you want

To exit, press Ctrl+X.  You’ll be prompted to save – just type Y
You’ll be prompted to confirm the filename – just press Enter

Set file properties
Once that’s done make sure the file has the right properties by typing the following:
sudo chmod 755 /etc/init.d/tightvncserver

NOTE: Important to do this step every time you modify this file.

Add File to startup sequence
And now just add your file to the list of startup actions by typing the following:
sudo update-rc.d tightvncserver defaults

And that should be it!  Just restart, and you should be able to VNC straight in!


I use Mocha VNC Lite on my iPad to connect and on my Mac I use RealVNC Viewer available to download from


A useful PDF document which includes the settings for RealVNC Viewer can be found here



Comments are closed.