Setting up VNC Access on the PI

September 29, 2014 | By More

I wanted to set up VNC on my Raspberry Pi so I could use it via a remote desktop on my MacBook Air. There are lots of instructions scattered in various places around the web, and I guess I’m going to add to that here. This is not a replacement for all the others but just how I did it.

Firstly, I completed the installation through a ssh session. You could also acheave the same through terminal through the GUI on the PI.

Right… At the terminal enter.

sudo apt-get update
sudo apt-get install avahi-daemon
sudo update-rc.d avahi-daemon defaults

So now I have installed the bonjour service on the PI. I can now find my PI on the network by using it’s hostname.local. In my case raspberry.local and so now pi@raspberrypi.local allows me access.

The next step is to configure the avahi service by entering

sudo vi /etc/avahi/services/afpd.service

And enter the following

<?xml version=”1.0″ standalone=’no’?><DOCTYPE service-group SYSTEM “avahi-service.dtd”>
<name>replace-wildcards = “yes” >%h</name>

Then I ran

sudo /etc/init.d/avahi-daemon restart

That got the bonjour service runing and configured.

Now the VNC Server

Back at the terminal I entered these commands…

sudo apt-get install tightvncserver; vncserver

You should now be able to set your VNC password. Choose wisely. The next step is a little configuring. Change in to the init.d dir buy entering

cd /etc/init.d; sudo vim tightvncserver

And enter the following in to vim



# Provides:          tightvncserver

# Required-Start:    $syslog

# Required-Stop:     $syslog

# Default-Start:     2 3 4 5

# Default-Stop:      0 1 6

# Short-Description: vnc server

# Description:



# Carry out specific functions when asked to by the system

case “$1” in


    su pi -c ‘/usr/bin/vncserver’

    echo “Starting VNC server “



    pkill vncserver

    echo “VNC Server has been stopped (didn’t double check though)”



    echo “Usage: /etc/init.d/blah {start|stop}”

    exit 1



exit 0

Save that with :wq and…

sudo chmod +x tightvncserver; sudo pkill Xtightvnc

Now check that VNC Server is NOT running with

ps aux | grep vnc

Which came back with

pi        3724  0.0  0.1   3520   740 pts/0    S+   14:07   0:00 grep --color=auto vnc

This shows no VNC server running only the command I ran to check.

Now… Almost there

[code language=”plain”]sudo /etc/init.d/tightvncserver start
cd /etc/init.d
sudo update-rc.d tightvncserver defaults[/code]

The next step will announce the VNC Server using bonjour. It just make life easier on the Mac.

Now I created the avahi rfb service by…

sudo vim /etc/avahi/services/rfb.service

And entering..


<?xml version=”1.0″ standalone=’no’?>

<DOCTYPE service-group SYSTEM “avahi-service.dtd”>


<name replace-wildcards=”yes”>%h</name>  






Finally restart the newly created service

sudo /etc/init.d/avahi-daemon restart

Now if all has gone weel and I’m sure it has you should see screen sharing being announce in the finder window

[code language=”plain”][/code]

Tags: ,

Category: RaspberryPI

About the Author ()

Comments are closed.