VNC Connect and Raspberry Pi

Follow

If you have Raspberry Pi OS (previously called Raspbian) Jessie, VNC Server is included with your Raspberry Pi. It’s completely free for non-commercial use; it just needs to be enabled.

*You’ll also need a VNC Viewer application for the Windows, Mac or Linux computer, or iOS or Android mobile device you want to control your Pi from. Get VNC Viewer.raspberry-pi-connect.png

Setting up your Raspberry Pi

VNC Server is included with Raspberry Pi OS (previously called Raspbian) but you still have to enable it.

*If you have an earlier version of Raspberry Pi OS (previously called Raspbian), or a different Linux distribution, you can install VNC Server yourself.

First, run the following commands to make sure you have the latest version:

sudo apt-get update 
sudo apt-get install realvnc-vnc-server 

If you’re already using an older version of VNC Server, restart it. If not, and you’re already booted into the graphical desktop, select Menu > Preferences > Raspberry Pi Configuration > Interfaces and make sure VNC is set to Enabled.

Alternatively, run the command sudo raspi-config, navigate to Interfacing Options > VNC and select Yes.

From now on, VNC Server will start automatically every time you boot your Raspberry Pi. 

*By default, VNC Server remotes the graphical desktop running on your Raspberry Pi. However, if your Pi is headless (not plugged into a monitor) or not running a graphical desktop, VNC Server can still give you graphical remote access using a virtual desktop.

Note you can also install VNC Viewer on your Raspberry Pi, in case you want to control a remote computer (or another Raspberry Pi!). To do this, use the Recommended Software program, or run the command sudo apt-get install realvnc-vnc-viewer.

Getting connected to your Raspberry Pi

There are two ways to connect; you can use either or both. Please make sure you’ve downloaded our VNC Viewer app to computers or devices you want to control from.

Establishing a direct connection

Direct connections are quick and simple providing you’re joined to the same private local network as your Raspberry Pi (for example, a wired or Wi-Fi network at home, school or in the office).

*If you’re connecting over the Internet, it’s much safer and more convenient to establish a cloud connection.

  1. On your Raspberry Pi, discover its private IP address by double-clicking the VNC Server icon on the taskbar and examining the status dialog:
    raspberry-pi-direct-address.png

  2. On the device you will use to take control, run VNC Viewer and enter the IP address in the search bar:
    raspberry-pi-direct-connect.png

Establishing a cloud connection

Cloud connections are convenient and encrypted end-to-end, and highly recommended for connections over the Internet. There’s no firewall or router reconfiguration, and you don’t need to know the IP address of your Raspberry Pi, or provide a static one.

You’ll need a RealVNC account; it’s completely free to set up and only takes a few seconds. We’ll give you a special version of our Home subscription that enables both cloud and direct connectivity, and also in-session features such as system authentication, file transfer, printing and chat.

*You can apply your Home subscription to five Raspberry Pis and/or desktop computers in total. Please note you revert to the standard feature set for Windows, Mac and Linux desktop computers.

  1. Sign up for a RealVNC account by entering your email address in the box on this page, and following the instructions.

  2. On your Raspberry Pi, select Licensing from the VNC Server status menu, choose Sign in to your RealVNC account, and enter your new account email and password:
    raspberry-pi-cloud-signin.png

  3. On the device you will use to take control, run VNC Viewer and sign in using the same account credentials.

  4. In VNC Viewer, a connection to your Raspberry Pi automatically appears under the name of your team. Simply tap or double-click to connect:
    raspberry-pi-cloud-connect.png

Authenticating to VNC Server

To complete either a direct or cloud connection you must authenticate to VNC Server. Enter the user name and password you normally use to log on to your user account on the Raspberry Pi.

By default, these credentials are pi and raspberry, but hopefully you’ll have changed them to something more secure by now!

Running directly rendered apps such as Minecraft remotely

KNOWN ISSUE: The "direct capture" option is not working when running VNC Server on Raspberry Pi OS with the KMS driver (vc4-kms-v3d). The Fake KMS driver (vc4-fkms-v3d) is not affected.
Enabling it will cause VNC Server to send a blank screen and you will lose remote access to the VNC Server. Our development team are investigating and hope to make a fix available in the near future. This issue affects all current versions of VNC Server, 6.9.1 and earlier.
If you have enabled direct capture and only have command line access to your Raspberry Pi, please follow the steps in this link to disable direct capture

VNC Server can remote the screen of Raspberry Pi apps that use a directly rendered overlay, such as Minecraft, the text console, the Pi camera module, and more.

raspberry-pi-minecraft.png

To turn this feature on, open the VNC Server dialog, navigate to Menu > Options > Troubleshooting, and select Enable direct capture mode. On the device you will use to take control, run VNC Viewer and connect (if already connected, you’ll need to reconnect).

If you’ve turned direct capture mode on and mouse movements seem erratic when using Minecraft remotely, try pressing F8 to open the VNC Viewer shortcut menu and selecting Relative Pointer Motion.

If performance seems impaired, try:

  1. On your Raspberry Pi, run sudo raspi-config, navigate to Advanced options > Memory Split, and ensure your GPU has at least 128MB.
  2. Reduce your Raspberry Pi’s screen resolution.

If you still encounter problems, please let us know.

Transferring files to and from your Raspberry Pi

You can transfer files to and from your Raspberry Pi providing you’re connecting from VNC Viewer running on a Windows, Mac or Linux desktop computer.

  • To transfer files to your Raspberry Pi, click the VNC Viewer VNC_Viewer_Toolbar_File_Transfer_Small.png toolbar button and follow the instructions. Detailed steps are here.
  • To transfer files from your Raspberry Pi, use VNC Viewer to open the VNC Server dialog remotely, select Menu > File transfer, and follow the instructions. Detailed steps are here.

Printing to a local printer

It can be really useful to print to a printer attached to your Windows, Mac or Linux computer if no printer is set up for your Raspberry Pi. To do this, first run the following command on your Raspberry Pi to install cups (the Common Unix Printing System):

sudo apt-get install cups

Then, connect to your Pi using VNC Viewer and perform whatever the standard operation is for printing the file you want to print (for example, select a text editor’s File > Print menu option). VNC Server directs the output to VNC Viewer, and spools it to your local printer. There’s more information about remote printing here.

Creating and remoting a virtual desktop

If your Raspberry Pi is headless (that is, not plugged into a monitor) or embedded in a robot, it’s unlikely to be running a graphical desktop.

VNC Server can run in Virtual Mode to create a resource-efficient virtual desktop on demand, giving you graphical remote access even when there is no actual desktop to remote. This virtual desktop exists only in your Raspberry Pi’s memory:

raspberry-pi-virtual.png

To do this:

  1. On your Raspberry Pi, run the command vncserver. Make a note of the IP address/display number printed to the console, for example 192.167.5.149:1.
  2. On the device you will use to take control, enter this information in VNC Viewer.

Stopping a virtual desktop

A virtual desktop persists until you explicitly destroy it. Run the following command when you are sure it is no longer needed:

vncserver -kill :<display-number>

Note this command will terminate any current connections without warning to those users.

Operating VNC Server at the command line

You can operate VNC Server exclusively at the command line or via SSH if you prefer.

Common commands for Raspberry Pi OS (previously called Raspbian) Jessie (which is based on Debian 8, and uses systemd) are:

  • To start VNC Server now: sudo systemctl start vncserver-x11-serviced.service
  • To start VNC Server at next boot, and every subsequent boot: sudo systemctl enable vncserver-x11-serviced.service
  • To stop VNC Server: sudo systemctl stop vncserver-x11-serviced.service
  • To prevent VNC Server starting at boot: sudo systemctl disable vncserver-x11-serviced.service

For equivalent commands for Raspberry Pi OS (previously called Raspbian) Wheezy (which is based on Debian 7, and uses initd), see this page.

Troubleshooting VNC Server

Changing the Raspberry Pi’s screen resolution

You may want to do this if:

  • Performance is impaired. A smaller screen resolution gives a more responsive experience.
  • Your Raspberry Pi is headless (that is, not plugged into a monitor) and the default initial screen resolution is too small.

To change the resolution, run the command sudo raspi-config, navigate to Advanced Options > Resolution, and choose an option.

If this menu is not available, or you want more control, specify settings in the /boot/config.txt file:

Setting Value Explanation
hdmi_force_hotplug 1 Tells your Pi an HDMI display is attached.
hdmi_ignore_edid 0xa5000080 Ignores EDID/display data.
hdmi_group 2 Defines the HDMI output group.
hdmi_mode 16 Forces (for example) 1024x768 at 60Hz.

See the Raspberry Pi documentation for more hdmi_mode options, and information on /boot/config.txt in general. You will need to reboot your Raspberry Pi for any changes to take effect.

Note that settings you specify in this file override monitors you subsequently plug in (unless you revert hdmi_force_hotplug), so pick a ‘headless’ resolution compatible with your regular monitor.

Specifying a screen resolution for a virtual desktop

If you run VNC Server in Virtual Mode to create a virtual desktop, you can specify the screen resolution (geometry) at start up, for example:

vncserver -randr=800x600

You can even specify multiple screen resolutions and cycle between them.

Optimizing for Raspberry Pi Zero and Pi 1

If performance is impaired for direct connections to a Raspberry Pi Zero or Pi 1, try turning off encryption if you are sure your private local network is secure. This reduces CPU usage.

*You cannot turn off encryption for cloud connections.

  1. On your Raspberry Pi, open the VNC Server dialog and select Menu > Options > Expert.
  2. Change the Encryption parameter to AlwaysOff.
  3. Restart any existing connections.

If performance is still impaired, try reducing your Raspberry Pi’s screen resolution.

Was this article helpful?
284 out of 368 found this helpful

Comments

6 comments
  • My RPi has been setup using the minimal image (i.e. without recommended programs and a desktop environment), I found that running the RealVNC server (as a systemd service) is somewhat different on this image to using the full blown RPi image (with desktop environment). I use i3 window manager as my desktop environment which shouldn't really make any difference to the way system services are run. However, when I clicked the "real vnc server" system tray icon and clicked "licensing" it failed to add my RPi to my RealVNC account. I went digging and discovered that running the licensing program this way wasn't running it with sudo priviliges and was the reason it was failing to add my RPi. What you need to do is run the following command:

    /usr/bin/vnclicensewiz

    with sudo priviliges whilst your "real vnc server" service is running. It will then authenticate and add your RPi to your RealVNC account.

    1
    Comment actions Permalink
  • Help - problem install VNC server on Rasp Pi running ubuntuMate V9.2
    I selected the correct version but when I install the package I get
    "Reading state information... Done
    libc6 is already the newest version (2.31-0ubuntu9.2)."
    Error says I need Libc6 V2.4 or higher.
    DO I have the correct download. I cannot upgrade libc6 and therefore the VNC server does not install or run. It is not pre-installed in my version.
    thnx

    0
    Comment actions Permalink
  • Things broke with vncserver upgrade from 6.7.4 to 6.9.1 (raspbian bullseye). I did a fresh install of raspberrypi OS (Raspbian bullseye) enable ssh and vnc. I have always started vncserver with "vncserver -geometry 2560x1440 :1". Connects fine with VNC Viewer (hostname:1). Desktop appears at correct resolution with Taskbar and Wastebasket. Then I upgraded raspberrypi OS using "sudo apt-get upgrade" installs a bunch of new updates including vncviewer and vncserver 6.9.1. After restarting vncserver using above method, when I connect with VNC viewer using hostname:1 I get the desktop at the correct resolution and the Wastebasket, but no Taskbar. I can't do anything except create a new file/folder and play with Desktop Preferences.

    0
    Comment actions Permalink
  • Hi, Brian!
    I faced the same problem. I also upgraded VNC Server to 6.9.1 version (on Raspberry Pi OS arm64). Try to connect as "hostname:0" (port 0 is your primary display, where taskbar is located).
    Port 1 is your virtual display (secondary)

    0
    Comment actions Permalink
  • Artem, I should have mentioned that hostname or hostname:0 work. But I need multiple instances and that appears to be broken with 6.9.1.

    -1
    Comment actions Permalink
  • Under the "Troubleshooting VNC Server" section above, subsection "Changing the Raspberry Pi’s screen resolution," this has changed. Under (at least) Raspbian v11 (bullseye), you still run `sudo raspi-config`, but instead of Advanced Options -> Resolution, the change should be made under Display Options -> VNC Resolution.

    0
    Comment actions Permalink

Please sign in to leave a comment.