How to Setup a VNC Server on Raspberry Pi

Raspberry Pi is a circuit board that runs an operating system customized for it, typically Raspbian. To work with Raspberry Pi, peripherals such as monitor, keyboard and mouse have to be connected to it. In case we don’t have a monitor, we can access Pi through SSH remotely. This is fine for most of the part. However, in some eccentric situations such as Wi-Fi setup, Python games etc., I require the convenience of GUI. VNC (Virtual Network Computation) protocol is designed to Remote Desktop other PCs running  VNC server with the help of a VNC client application.

Here are the steps to get VNC server up on the Raspberry Pi :

Step #1 : Connect RPi to the Internet.

You can connect the RPi to Internet directly via a Wireless USB adapter. Or You can bridge your Laptop’s Internet-connected Wi-Fi interface and the LAN adapter connecting to the RPi board. Whichever the way you prefer, make the RPi to reach out to the Internet.

Step #2 : Update the repo index files and install the VNC Server package.

If you SSH’ed RPi as the user “pi“, you should run the commands as “sudo” which elevate the privileges to that of root. The default password for the user pi is “raspberry“.

sudo apt-get update

After syncing the apt’s repo index files, install the  “x11vnc” package which will enable us to run the VNC server on RPi.

sudo apt-get install x11vnc

x11vnc installation

Step #3 : Set the VNC password.

After installing the x11vnc package, set the VNC server password like so:

x11vnc -storepasswd


Step #4 : Add the VNC autostart making VNC server start during booting.

In case autostart directory doesn’t exit, create it first.

cd .config
mkdir autostart
cd autostart

Inside the autostart directory, create a file named x11vnc.desktop with the following lines:

[Desktop Entry]
Comment="VNC server"
Exec=x11vnc -forever -usepw -display :0 -ultrafilexfer


Step #5 : Reboot Raspberry Pi and connect to it from a VNC client such as RealVNC viewer, TightVNC viewer or UltraVNC viewer. I liked UltraVNC’s auto scaling option which will automatically scale the screen size to fit the full window.


RealVNC client is also available as an Android app using which I can connect to the Raspberry Pi from my smart phone.


About Deepak Devanand

Seeker of knowledge
This entry was posted in Raspberry Pi and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s