In this tutorial, we will be going to set up a VNC Server on the Raspberry Pi.
VNC is a special protocol that is designed to allow one device to control another remotely. This protocol works differently to the Remote Desktop Protocol that Windows uses.
Using VNC on your Raspberry Pi has a variety of uses. For example, you can use it to view your Pi’s desktop without having a monitor attached to it. This removes the need to use SSH as the only way of accessing your Raspberry Pi.
Setting up a VNC server on your Raspberry Pi is relatively straightforward and requires us to install and setup a single package called
TightVNC is the software that will allow us to set our Pi up to accept VNC connections easily. It is both lightweight, free, and open-source that makes it perfect for the device.
If you just want a barebones command-line approach, then be sure to check out the tutorial on how to SSH into your Raspberry Pi.
One thing to note is that VNC creates a virtual desktop for the connection. If you want to share your Raspberry Pi’s desktop, check out our guide on using Vino.
While Vino implements the VNC protocol, it works by showing the current user’s desktop rather than creating the virtual desktop that TightVNC and other server software use.
To complete this tutorial on installing a VNC server on the Raspberry Pi, you will need the following equipment.
If you do not currently have an operating system installed be sure to check out our guide on using NOOBs to install an OS.
If you want to see how we install the VNC Server, then be sure to check out my video below. We go through all the steps from start to finish on getting this set up in no time at all.
We have also included written instructions below, so if you have trouble with the video feel free to use the steps below.
Adblock blocking the video? Support us by subscribing to our ad-free service.
Installing the VNC Server Software on your Raspberry Pi
By following this guide, you will find out how easy it is to install and configure a VNC server on your Raspberry Pi.
1. Before we install the VNC software to our Raspberry Pi, we need to make sure our operating system is up to date.
To update the packages running on our device, we need to run the following two commands.
sudo apt update sudo apt upgrade
2. Once your Raspberry Pi has finished installing all of the updates, we can move on to installing the VNC Server.
tightvncserver package is available through the Raspbian repository, all we need to do is run the following command.
sudo apt install tightvncserver
Configuring the VNC Server on your Raspberry Pi
Now that you have the VNC server installed to your Raspberry Pi, we can now learn how to configure it so that it is ready for connections.
1. With the VNC server now installed to our Pi, let us now proceed to configure it.
To start the configuration process, we need to run the command below.
2. You will now need to set up a password for when you connect to the Raspberry Pi remotely via a VNC client.
Make sure the password that you set is no longer than 8 characters long. Any password that is longer than 8 characters will be truncated (Meaning any letters after the eighth will be removed).
You will require a password to access your desktops. Password:
As this password will give someone access to your Raspberry Pi’s desktop, make sure you set this to something secure.
3. You will next be asked to re-enter the password again to verify it.
4. Next, you will be asked if you want to set up a separate view-only password.
A view-only password means that a user will be able to view the desktop using VNC but not interact with it.
For our tutorial, we will be skipping this step by typing in n and pressing the ENTER key.
Would you like to enter a view-only password (y/n)?
5. Your VNC server should now be up and running on your Raspberry Pi.
However, whenever you restart your Pi, you will need to restart the software by rerunning the following command.
If you want to have the software startup automatically at bootup, then simply follow the next couple of steps. Otherwise, we are ready to set up the client-side of things.
Starting the VNC Server at Startup
Having to run the command above every time you want to use VNC on your Raspberry Pi is not ideal. To deal with this, we will make the VNC server software startup at boot.
The following steps are pretty straightforward and take you through the steps of having the server startup on boot.
We will also show you how to stop and disable the service if you ever want to stop using VNC on your Raspberry Pi.
Creating the service for VNC
As the VNC server software we are using does not have a systemctl compatible service, we will need to write our own.
Luckily for us, the process of writing a service file is a very straightforward one.
1. To get our VNC software to start on boot, we will need to write a service file for it on our Raspberry Pi.
To begin creating our service, run the following command.
sudo nano /etc/systemd/system/vncserver.service
We will be calling this service
2. Within this file, we need to enter the following lines.
[Unit] Description=TightVNC remote desktop server After=network.target [Service] User=pi Type=forking ExecStart=/usr/bin/vncserver :1 ExecStop=/usr/bin/vncserver -kill :1 [Install] WantedBy=multi-user.target
These lines tell the service manager how to handle the VNC server on our Raspberry Pi.
We are telling it to start the VNC server software after the network has become available.
We tell it to run the VNC server available at the location,
For both commands defined in the service, we use
:1, which tells it that we are using the first VNC virtual desktop.
We also tell the service that when it is shutting down, it should use the
-kill argument to stop the virtual desktop.
3. Once you have finished entering all the data into the service file, you can save it by pressing CTRL + X, then Y, followed by the ENTER key.
Starting the VNC Server on the Raspberry Pi
We can now test to see if our new VNC service is working by running the following command to start it.
sudo systemctl start vncserver
If the service says it’s failed, try checking the status of it to find out where.
Checking the Status of the VNC Server
Let us now check the status of the VNC service to see if it has started up correctly.
To retrieve the status of the service, use the command below.
sudo systemctl status vncserver
If everything is now working as intended, you should see the text
Active: active (running).
If the service is marked as failed, look for the text “
A VNC server is already running as :1“. This text means our command is correct, but the VNC Server has already been started.
You can kill the existing VNC desktop that’s running on your Raspberry Pi run the following command.
vncserver -kill :1
Once the running VNC server has been killed, you can try starting the service again.
Telling the VNC Server to Start at Boot
Once we have verified that the VNC service is now functioning, we can tell it to start at boot.
To get our new service to start at boot is to enable the service by using the command below.
sudo systemctl enable vncserver
Stopping the VNC Server
If, for any reason, you may want to stop the VNC server on your Raspberry Pi, all you need to do is use the following command.
sudo systemctl stop vncserver
Disabling the Start at Boot on the Raspberry Pi
If you don’t want the VNC server to start at boot, you can stop it from starting up by using the command below.
sudo systemctl disable vncserver
Setting up a VNC client on your PC
Installing and setting up a VNC client on your computer is an incredibly easy process.
There are quite a few different VNC software packages out there, but in this tutorial, we will be using RealVNC.
1. To begin head over to the RealVNC website and download the VNC viewer client relevant to your operating system.
2. Once downloaded, open it up. (If you want server software as well, you will need to download the full software package.)
3. Enter the IP address of your Raspberry Pi followed by the port (
:) 1 in the field that says VNC server.
For example, the setting we used is, 192.168.1.108:1
4. Now, press the “Connect” button.
5. It should then give you a warning message as we have not previously connected to our Raspberry Pi.
To proceed, click the “Continue button.
6. Then it will ask you for the password you set earlier when you installed the VNC server software.
Enter the password to connect to your device.
7. The VNC window should load, and you will now have remote access to your Raspberry Pi’s interface.
If you do come across any issues, we have a small troubleshooting section below that you can try following.
- I can’t connect! – Be sure to double-check the IP you entered and make sure it is the same as the Pis. Also, be sure to make sure that the VNC server software is running. Most routers also dynamically give out IP’s, so the IP may change over time. To fix this, set up a static IP or check the IP address whenever you go to connect.
- I want to access it outside of my local network – This will open security issues, but you can do this by setting up port forwarding. Remember, the VNC server is running on port 1.
- I want a different/larger sized screen on my VNC client – When you go to start the VNCserver, you can add an extra command called geometry and then the screen size width and high you want (This is in pixels). The command is:
vncserver :1 -geometry 1440x900
We hope that at this point, you will have successfully gotten the VNC server software up and running on your Raspberry Pi, and you can now use it to view your desktop.
If you feel like there is something wrong with this tutorial, then feel free to leave a comment below.
You can find some of our latest DIY Raspberry Pi Projects by browsing our website.