How to Set Up and Use VNC on Raspberry Pi: A Complete Guide for Remote Access
Sep 14, 2024

Why Use VNC on Raspberry Pi?
As a popular Raspberry Pi remote desktop method, VNC offers great flexibility. The primary advantage of using VNC with Raspberry Pi is the flexibility it provides.We can run the headless Raspberry Pi in "headless mode" (without a physical display)and still have full access to its graphical user interface (GUI). This reduces the need for additional hardware, making setups more affordable and efficient. Whether we’re a hobbyist developing projects, an educator managing a classroom full of Pis, or someone experimenting with IoT devices, VNC offers a user-friendly, customizable way to control and manage the Raspberry Pi remotely, whether you’re following a Raspberry Pi setup tutorial to get started or refining your workflow as you go.

Remote access: Control your Raspberry Pi from anywhere without needing a separate monitor—a classic use case of remote access Raspberry Pi setups.
Integration: VNC is compatible with various operating systems (Windows, macOS, Linux), making it versatile for users with different setups.
Multiple Device Access: Several devices can connect to and control the Raspberry Pi simultaneously, making it versatile for users with different setups, especially those using VNC on Raspberry Pi across platforms.
Step-by-Step Guide to Setting Up VNC on Raspberry Pi
1. Upgrade Raspberry Pi OS Bookworm (IMPORTANT STEP)
To ensure Raspberry Pi Bookworm VNC works correctly, open the terminal and run:
sudo apt-get update
sudo apt-get upgrade
sudo apt full-upgrade
For more information about this commands, visit:
https://www.sunfounder.com/blogs/news/raspberry-pi-update-essential-steps-for-a-secure-and-optimized-system
2. Enable VNC on Raspberry Pi by running the following command in Terminal:
sudo raspi-config
Navigate to the VNC interface under Interface Options and select Enable.


3. Reboot
Connect to Raspberry Pi Using VNC
Begin your VNC Viewer setup by downloading and installing the software https://www.realvnc.com/en/connect/download/viewer/

1. Open VNC Viewer tool on your computer
2. Go to File > New Connection
Complete VNC Server with your IP address (also referred to as your VNC IP address).

Raspberry Pi 5, Bookworm and RealVNC Connect
Raspberry Pi 5 VNC configurations require special attention after the Bookworm OS update. With the release of Raspberry Pi 5 and the transition to the Bookworm (Debian 12) operating system, the setup process for RealVNC Connect (previously RealVNC) has some adjustments compared to earlier versions.
Real VNC official stanament: https://help.realvnc.com/hc/en-us/articles/14110635000221-Raspberry-Pi-5-Bookworm-and-RealVNC-Connect#statement-0-0
At the moment, RealVNC Connect does not support Wayland for Linux systems. If we don't disable Wayland, when we connect to RealVNC Server on these OS we will see a blank/blank screen or a message stating "Cannot currently show the desktop", or find we cannot connect until there is a user logged in on the remote computer. For detailed hardware setup and system configuration advice, see Set up Your Raspberry Pi.The RealVNC Server GUI may also fail to load.
1. Open Terminal and run the command:
sudo raspi-config
2. Navigate to > Advanced Options, then select Wayland

3. Select X11

4. Reboot and connect to Raspberry Pi using VNC Viewer

Advanced Configurations
Set a VNC Password
We need to set a password that will be used to connect remotely:
To begin VNC password setup, open Terminal and run the command:
Vncpasswd
2.Restart VNC Server
service vncserver-x11-serviced restart
Alternative VNC Password with VNC Connect:
1. Go to Options

2. Go to Security tab and select Autentication: VNC password

3. Select “Standard user” and set the Password then Apply the configuration.

RealVNC Cloud
RealVNC Connect makes it easy to access your Raspberry Pi remotely over the internet over the internet (not just on your local network), we’ll need to connect to RealVNC Cloud
1. Create a RealVNC account at RealVNC Connect.
2. Sign in to VNC Server on your Raspberry Pi:
Open VNC Server on your Pi (from the desktop, go to Menu > Preferences > Raspberry Pi Configuration > Interfaces, and ensure VNC is enabled).
Click the VNC icon in the taskbar, and choose Sign In. Enter your RealVNC email,password to sign in — learn how to use VNC Connect remote desktop in official RealVNC guide.

3. Access Raspberry Pi from Anywhere:
From VNC Viewer on another device, sign in with the same RealVNC account, and we’ll see your Raspberry Pi listed for remote access— refer to the complete VNC remote access guide on SunFounder for detailed steps.
Troubleshooting Common Issues
Black or Blank Screen in Headless Mode
In common Raspberry Pi VNC troubleshooting cases, when we connect via VNC without a monitor, the screen appears black or blank.
Set a virtual resolution for the display if the Pi is in headless mode (no monitor attached):
sudo raspi-config
Navigate to Display Options > Resolution, and select an appropriate resolution such as 1280x720.
Alternatively, we can edit the /boot/config.txt file to force a specific resolution:
sudo nano /boot/config.txt
Add or uncomment the following lines:
hdmi_force_hotplug=1
hdmi_group=2
hdmi_mode=82
sudo reboot
Slow or Laggy VNC Performance
The remote desktop lags or freezes during use.
Network Quality: Ensure both the Raspberry Pi and the device we’re connecting from are on a fast and stable network. If using Wi-Fi, consider switching to Ethernet for a faster and more stable connection.
Change the VNC Encoding Settings:In the VNC Viewer, go to Options (cog icon) and adjust the encoding. ZRLE or Hextile encodings use less bandwidth but may sacrifice image quality for better performance.
Reduce Screen Resolution: If the remote desktop experience is slow, try reducing the resolution of your Raspberry Pi display (either in raspi-config or in the desktop settings) to lower the strain on the connection—see how to adjust VNC resolution on Raspberry Pi in the official RealVNC guide.
Conclusion
VNC is a powerful and flexible tool for remote access to your Raspberry Pi, allowing you to manage projects efficiently without the need for additional hardware. Whether you're working on a local network or accessing your Raspberry Pi from anywhere via the internet, VNC provides a seamless experience. By securing your connections and optimizing performance, you can ensure smooth remote operations. With the steps and tips outlined in this guide, you’ll be wellprepared to fully utilize VNC with your Raspberry Pi, including following the Raspberry Pi VNC setup instructions from the official documentation.
