Take Control Remotely with Raspberry Pi VNC

Published:17 April 2023 - 4 min. read

Nicholas Xuan Nguyen Image

Nicholas Xuan Nguyen

Read more tutorials by Nicholas Xuan Nguyen!

If you are seeking an effortless way to remotely control your Raspberry Pi’s GUI, Virtual Network Computing (VNC) is the ideal solution.

With Raspberry Pi VNC, you can remotely access your device’s GUI, no matter where you are. And in this tutorial, you will walk through the steps of setting up and using VNC on your Raspberry Pi.

Read on and take complete control of your Raspberry Pi from anywhere!

Prerequisites

This tutorial houses hands-on demonstrations. To follow along, be sure you have the following:

  • A Raspberry Pi – This tutorial uses a Raspberry Pi model 4B with Raspbian Bullseye installed.
  • A host machine with the VNC viewer client installed to access the Raspberry Pi remotely – This tutorial uses Windows 10.
  • A stable internet connection.

Installing Raspberry Pi VNC

SSH is a valuable tool when accessing the command line interface of the Raspberry Pi remotely and securely without needing a GUI. But many tasks require a GUI, such as running applications or remotely controlling the desktop of your Raspberry Pi. In such cases, VNC comes in handy.

With VNC, you can remotely access the Raspberry Pi’s desktop environment and control it as if sitting in front of it. But before using VNC, you must install the VNC Server on your Raspberry Pi.

Open a terminal, and run the following apt update command to update the list of available packages. Doing so ensures you have the latest version of the VNC Server.

sudo apt update
raspberry pi vnc - Updating the list of available packages
Updating the list of available packages

Now, run the following apt install command to install the VNC Server package, specifically two packages as follows:

PackageDetails
realvnc-vnc-serverThe package for the actual VNC Server software that runs on the Raspberry Pi
realvnc-vnc-viewerA separate program that allows you to connect to and control the Pi’s desktop environment from another device.
sudo apt install realvnc-vnc-server realvnc-vnc-viewer
Installing the VNC Server package
Installing the VNC Server package

Enabling the VNC Server

Installing the VNC Server does not automatically run it. Post installation, you must enable the VNC server on your Raspberry Pi. Enabling the VNC Server starts the VNC service, which allows incoming connections on Raspberry Pi’s network port (5900).

To enable the VNC server, follow these steps:

1. Run the below raspi-config command to open the Raspberry Pi configuration tool.

This tool allows you to configure various system settings, such as:

  • Enabling/disabling interfaces.
  • Setting up networking options.
  • Changing the Raspberry Pi hostname, and much more.
sudo raspi-config

Navigate to Interfacing Options and press Enter to access a list of interface options.

Accessing the list of interface options
Accessing the list of interface options

2. Next, select VNC from the list below and press Enter to enable your VNC Server.

Enabling the VNC Server
Enabling the VNC Server

3. When prompted, select <Yes> and press Enter to confirm enabling your VNC Server.

Confirming enabling the VNC Server
Confirming enabling the VNC Server

4. Once the VNC Server is enabled, press Enter to continue.

Confirming the VNC Server is enabled
Confirming the VNC Server is enabled

5. Now, press Tab to highlight the <Finish> button and Enter to exit the configuration tool.

Exiting the configuration tool
Exiting the configuration tool

6. Next, run the below command, which does not produce output, but restarts (reboot) your Raspberry Pi to apply the changes.

sudo reboot

7. Once your Raspberry Pi boots up, run the below systemctl command to check the status of the VNC service.

sudo systemctl status vncserver-x11-serviced.service

If all goes well, you will see an output similar to the one below that shows the VNC server is active (running).

Checking the VNC service’s status
Checking the VNC service’s status

8. Lastly, run the hostname command below to get all IP addresses (-I) associated with your Raspberry Pi.

hostname -I

Note down your Raspberry Pi’s IP address, as shown below. You will need this IP address to connect to your Raspberry Pi later.

Finding the Raspberry Pi’s IP address
Finding the Raspberry Pi’s IP address

Connecting to the Raspberry Pi Remotely

With the VNC Server running, you can now remotely connect to your Raspberry Pi. How? You will use the VNC Viewer from your host machine.

To connect to your Raspberry Pi remotely:

1. Open the VNC Viewer program on your host machine.

2. Enter your Raspberry Pi’s IP address, as shown below, and press Enter to establish a remote desktop connection to your Raspberry Pi.

Connecting to the Raspberry Pi remotely
Connecting to the Raspberry Pi remotely

3. When prompted, click Continue to authorize the remote connection to your Raspberry Pi.

This warning message only appears when you connect to your Raspberry Pi remotely using VNC for the first time.

Authorizing the remote connection
Authorizing the remote connection

4. Finally, enter the root user and password of your Raspberry Pi and click OK to log in.

In most cases, the default username is pi, and the password is the one you set during the initial setup of your Raspberry Pi (not the one above).

You need to provide the username and password of the administrative account on your Raspberry Pi to gain access to perform administrative tasks on the Raspberry Pi.

Logging in to the Raspberry Pi
Logging in to the Raspberry Pi

If everything is set up correctly, you will see the Raspberry Pi’s desktop environment in your VNC Viewer window, as shown below.

Congratulations! You now have complete control of your Raspberry Pi’s desktop environment remotely. Feel free to securely access your files, install packages, and perform tasks to your heart’s content.

Accessing the Raspberry Pi remotely
Accessing the Raspberry Pi remotely

Conclusion

Whether you are a developer, hobbyist, or educator, remote access via Raspberry Pi VNC can be a valuable tool for various applications. And in this tutorial, you learned how to set up VNC Server on your Raspberry Pi and establish a remote connection via the VNC Viewer.

With a fully functional VNC Server, securely accessing your Raspberry Pi remotely only takes a few clicks. Take advantage of Raspberry Pi’s powerful computing capabilities from anywhere.

Now, why not learn how to stream a PiCamera video stream as a background in your Raspberry Pi’s VNC Server? Or create a motion detector using the same VNC-enabled Raspberry Pi?

Hate ads? Want to support the writer? Get many of our tutorials packaged as an ATA Guidebook.

Explore ATA Guidebooks

Looks like you're offline!