Raspberry Pi VNC Server: Setup Remote Desktop for your Pi

In this tutorial, I will go through the all the steps to setting up a Raspberry Pi VNC server.

Raspberry Pi VNC Server

Once we have setup the VNC server, you will be able to remote desktop to your Pi, so you’re able to control as if you were sitting there with it.

The process of setting VNC all up is pretty easy, and at the end of it, you will be able to control the desktop of the Pi remotely.

This software is incredibly handy if you don’t have a screen or access to the Pi itself. 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. This method is how I control my Pi pretty much all the time, but it all just comes down to preference.

It’s important to mention that Raspbian now has a VNC server package pre-installed. You can still do this tutorial if you wish otherwise go into the Raspberry Pi configuration and turn it on. Once you have turned it on, simply connect using the same steps as described in this guide.

Equipment

To complete this Raspberry Pi remote desktop tutorial, you will need the following pieces of equipment.

Recommended

Raspberry Pi

Micro SD Card (16gb+ is recommended)

Ethernet Cord or Wifi dongle

Optional

Raspberry Pi Case

USB Keyboard

USB Mouse

Video

If you want to see how this is all done, then be sure to check out my video below. I go through all the steps from start to finish on getting this setup correctly in no time at all.

If you do like the video and would love to see more, then please make sure you subscribe.

Adblock blocking the video? Support us by subscribing to our ad-free service.

Installing the Raspberry Pi VNC Server

As in all of my tutorials, you will need to have Raspbian pre-installed onto your Raspberry Pi. If you haven’t already done this, then you can find out how to do it all in my guide to installing Raspbian.

Now installing the VNC server software package onto your Raspberry Pi is actually incredibly easy and only requires entering a couple of commands.

1. Before we get started first make sure your Pi is up to date by running the following commands:

sudo apt-get update
sudo apt-get upgrade

2. Once those two commands have finished running, enter the following to install the tightvncserver.

sudo apt-get install tightvncserver

3. Now, set up and run the VNC server, this is pretty easy to do. Simply run the following command:

vncserver :1

4. You will now need to set up a password for when you go to connect to the Pi remotely via the VNC client. It is important to remember the password will be truncated to eight characters so try and choose a password that works best for you that is no longer than eight characters long.

5. It will next ask you to verify the password, enter it again.

6. Next, it will ask if you want a separate view only password, simply enter “n” for this.

7. Once that is all done, the server will be up and running. The following command will need to be run every time the Pi reboots, or for some reason, the process is stopped.

vncserver :1

The Raspberry Pi VNC server should now be up and running correctly. If you want to have the software startup automatically at boot up then simply follow the next couple of steps, otherwise we’re ready to setup the client side of things.

Start the VNC Server Automatically

Having to run the command above is not ideal so you might want to have it start automatically whenever your Pi is booted up.

The following steps are pretty straightforward and will take you through the steps of having the server startup on port 1 at boot up.

1. First, open up the rc.local file by entering the following command.

sudo nano /etc/rc.local

2. Now enter the following before the exit 0 line.

su - pi -c '/usr/bin/tightvncserver :1'

3. Save and exit by pressing ctrl + x then y.

4. Restart the Pi by running the following command.

sudo reboot

5. You can confirm that it is running by running the following command.

vncserver:1

6. It should say “A VNC server is already running at :1”

7. If you need to kill the server simply enter the following command (Change 1 if you’re using a different port):

vncserver -kill :1

Once you’re done, you can proceed to set up the client on your other computer, tablet or whatever device you plan on using.

Setting up the VNC client on your PC

Installing and setting up a VNC client on your computer is incredibly easy. There are quite a few different VNC software packages out there, but in this tutorial, I am going to 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, simply open it up. (If you want server software as well you will need to download the full software package.)

3. Enter your IP address with the port 1 in the field that says VNC server. For example, mine is, 192.168.1.108:1

realvnc connect screen
4. Now simply press connect.

5. It should then give you a warning message, simply press continue on this.

vnc security warning

6. Then it will ask you for the password you set for it earlier. Simply enter the password that we set earlier.

7. The VNC window should load, and you will now have remote access to your Raspberry Pi.

This process is all you need to do to have Raspberry Pi remote desktop up and running. If you do come across any issues, I have small troubleshooting section below otherwise be sure to leave a comment.

Troubleshooting

  • 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 it is possible the IP will change over time. To fix this setup a fixed IP or check the IP whenever you go to connect.
  • I want access outside my local network – This will open security issues, but you’re able to 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

I hope that you have been able to setup your Raspberry Pi VNC server correctly and that you’re able to remove desktop to your Pi easily.

If you’re still having trouble or that I have missed something, then please feel free to drop a comment below. If you’re looking for more, then be sure to check out some of my latest DIY raspberry pi projects.

14 Comments

  1. lawbut2 on

    I can connect to my Raspberry Pi from a VNC client, but it’s not the same session as the console? How can I connect to the console so if I have stuff already on the screen on the console, I can continue working on the same screen from anywhere else within my home?

    1. Gus on

      Hey lawbut2,

      This is how the default VNC client is designed to be, there is a solution for sharing the same screen and we plan on putting out a tutorial on that subject in the near feature.

      Cheers

  2. Don Oakes on

    Great article Gus. It’s been years since playing with this stuff so trying to get back into it. I am living Cambodia and have an issue trying to install Samba. All the Mirror sites are coming back ‘Failed to fetch…’ I am using two different ISP and get the same response. Funny though, only SAMBA so far with this issue. Any ideas?
    Again great article(s).

  3. Idham on

    Hi, thanks for the sharing.
    I followed all steps from yours and it already connected.
    However, I don’t know why when I connected to that network, it seemed to be freeze.
    I couldn’t do anything on the Raspberry pi

  4. Meeta on

    While I enter IP address in VNC viewer, should I remove connections between my R Pi and TV, which is connected using HDMI? And only power should be given to the Raspberry Pi?

    1. Gus on

      No you don’t need to remove the connections. However, if you’re worried about privacy then I would unplug them.

  5. James on

    Can you set the VNC screen size to 2550×1440?

    1. Gus on

      I haven’t tried but you can attempt it by starting vncserver with the following line.

      vncserver :1 -geometry 2550x1440

  6. Jan Hedström on

    Hi, thanks for the guide, I have one problem
    I cant get it to start automatically, I followed your guide step by step…
    I have RPI 3
    And second question, how can i get it to copy the HDMI screen, now it starts a new desktop ?

  7. Ivaylo on

    Hello,
    great tutorial , but i have permission problems with tightvnc after install, i cannot pretty much copy anything that has owner root . How can the tight vnc user be fixed to have sudo ?

  8. Marco Stoffers on

    It can be more simpeler, use the command:

    apt-get install xrdp

    After the install you can use as example the windows remote desktop client.

  9. Tony Goodhew on

    Could you please explain how to set up the Port Forwarding so that it can be used outside the local network, such as at a Raspberry Jam?

  10. Tony Goodhew on

    Thank you very much. I’ve tried to set this up several times but not managed it before. This worked first time once I’d made my IP address static. Great for my next robotics project.

  11. Robert on

    Useful tutorial, VNC is great (and easy) to use. I have also recently tried nomachine for raspberry pi as my remote access protocol. Tons faster, and gives me some extra functionality. Have you tried this or any others? It’s be nice to see other tutorials of similar products.

Leave a Reply

Your email address will not be published. Required fields are marked *