Start with a current Raspberry Pi OS image (the system formerly called Raspbian) and get the board onto your network, either over Ethernet or Wi-Fi. Then enable the SSH and VNC interfaces. You can do that in the Raspberry Pi Configuration tool on the desktop, or run sudo raspi-config and pick Interface Options if you’re working from the command line. That’s the core of how to setup VNC on Raspberry Pi, and it takes a couple of minutes.
Once the interfaces are on, the Pi is ready for remote work. You can Run a game server or any other application on it by installing the packages it needs, and still manage everything from another machine.
Next, install a VNC viewer on the computer you’ll connect from. Enter the Pi’s IP address (running hostname -I on the Pi will show it), sign in, and the Pi’s desktop appears in a window. Keep the connection on your home network, or put it behind a VPN, if you want to reach the Pi from anywhere without exposing it directly to the internet.
What You’ll Need
To set up VNC on your Raspberry Pi, you’ll need a Raspberry Pi 2, 3, or 4 with a power supply and microSD card (8GB or larger). Install the latest version of Raspberry Pi OS (32-bit) using the Raspberry Pi Imager. A monitor, keyboard, and mouse are required for initial setup, but can be removed once VNC is configured for Raspberry Pi Remote Desktop access. Ensure your Raspberry Pi is connected to the same network as the computer you’ll use to access it remotely. You’ll also need VNC Viewer installed on your remote computer (available for Windows, macOS, Linux, iOS, and Android).
Step 1: Setting Up Your Raspberry Pi
Install the Operating System
To install Raspberry Pi OS, download the official image from the Raspberry Pi website. Use a tool like Etcher to flash the image onto a microSD card. Insert the card into your Raspberry Pi and connect it to a monitor, keyboard, and mouse. Power on the device and follow the on-screen instructions to complete the initial setup, including setting your language, time zone, and a new password for the default “pi” user account. Alternatively, you can install other compatible operating systems like Ubuntu, Manjaro, or DietPi, depending on your specific needs and preferences. Ensure your chosen OS is compatible with your Raspberry Pi model before proceeding with the installation.
Connect Peripherals and Power On
To set up your Raspberry Pi, connect a USB mouse and keyboard to the available ports. Next, attach an HDMI cable from your monitor to the HDMI port on the Pi. If your monitor lacks an HDMI input, you may need an adapter or a different cable, such as DVI or VGA, depending on the available ports.
Once all peripherals are connected, plug the power supply into the micro USB port on the Raspberry Pi. The Pi will boot up, and you should see the Raspberry Pi OS desktop on your monitor. If the screen remains blank, verify that the cables are securely connected and the monitor is set to the correct input source.

Enable SSH
To enable SSH on your Raspberry Pi, open the terminal and run the command “sudo raspi-config”. Navigate to “Interfacing Options” and select “SSH”. Choose “Yes” to enable SSH server and press “Enter”. Select “Ok” and then “Finish” to exit the configuration tool. Your Pi is now accessible via SSH for remote access.
Step 2: Installing and Configuring VNC Server
Install VNC Server
To install the VNC server on your Raspberry Pi, simply open a terminal and run the following command:
“`
sudo apt-get install realvnc-vnc-server
“`
This command will download and install the VNC Connect package from RealVNC, which includes both the VNC server and viewer components. The installation process is straightforward and should only take a few moments. Once the installation is complete, the VNC server will be automatically started, and your Raspberry Pi will be ready for remote access. In the next section, we’ll cover how to configure the VNC server to ensure a secure and efficient remote connection.
Configure VNC Server Settings
To configure your VNC server settings, open the VNC Server Configuration window. Under “Security,” set the Authentication method to “VNC password” for a basic level of security. Choose a strong password and click “Apply.”
Next, click on “Options” and set the Resolution to match your client device for optimal viewing. You can also adjust the Color depth if needed.
Under “Troubleshooting,” enable “Try to detect if the desktop is not in use” to prevent unauthorized access when you’re actively using the Pi. This setting locks the VNC server when a keyboard or mouse is detected.
For advanced users, explore the “Users & Permissions” tab to set up multiple user accounts with different access levels. You can also configure the VNC server to start automatically on boot under “Service.”
Remember to click “Apply” after making any changes, then restart the VNC server for the new settings to take effect.

Set Up VNC to Start Automatically
To configure the VNC server to start automatically on boot, open the terminal and run:
sudo raspi-config
Navigate to “System Options” and select “VNC” to enable the VNC server at boot. Alternatively, you can manually start the VNC server on boot by adding the following line to the /etc/rc.local file (before the exit 0 line):
/usr/bin/vncserver -geometry 1280x720 :1
This command starts the VNC server with a resolution of 1280×720 on display :1. Adjust the resolution as needed. Save the file and reboot your Raspberry Pi. The VNC server will now start automatically, allowing you to connect remotely without manually starting the server each time.
Step 3: Installing and Using a VNC Viewer
Install a VNC Viewer
To access your Raspberry Pi remotely, you’ll need a VNC viewer installed on your client device. We recommend using RealVNC’s VNC Viewer, which is available for Windows, macOS, Linux, iOS, and Android. Visit the official RealVNC website and download the appropriate version for your operating system. For desktop systems, run the installer and follow the on-screen instructions to complete the installation process. On mobile devices, simply install the VNC Viewer app from the App Store or Google Play Store. Once installed, you’ll be ready to connect to your Raspberry Pi remotely using the VNC protocol.

Connect to Your Raspberry Pi
To connect to your Raspberry Pi using VNC Viewer, start by launching the application on your computer. In the address bar, enter the IP address of your Raspberry Pi, which you can find by running “hostname -I” in the terminal or using a network scanner. If you’ve enabled authentication, enter your username and password when prompted. For enhanced security, consider using a VPN or proxy to hide your IP address during the connection process. Once connected, you’ll see your Raspberry Pi’s desktop environment, allowing you to interact with it as if you were using it directly. You can now launch applications, access files, and perform various tasks remotely. If you encounter any connection issues, double-check your network settings, firewall rules, and VNC server configuration on the Raspberry Pi to ensure everything is set up correctly.
Troubleshooting Tips
If you can’t connect to your Raspberry Pi over VNC, start with the basics. Confirm that both devices are on the same network and that you’re using the Pi’s current IP address. Run hostname -I on the Pi to double-check it, since a router can hand out a new address after a reboot.
Next, make sure VNC Server is actually running. On a recent Raspberry Pi OS install, sudo systemctl status vncserver-x11-serviced will tell you in a few seconds. If it’s stopped, enable VNC under Interfaces in sudo raspi-config and restart the service.
Then look at the port. The VNC default port 5900 needs to be reachable from the machine you’re connecting from. On a home network this usually isn’t an issue, but a firewall on the Pi or a locked-down router can block it. If you’re connecting from outside your network, forward the port on your router, or better, use a VPN or RealVNC’s cloud connection instead of exposing 5900 directly to the internet.
Seeing a black screen or a “Cannot currently show the desktop” message? That usually happens when the Pi boots without a monitor attached. Set a fixed resolution under Display Options in raspi-config, or pick a resolution in the VNC Server options, and reboot. It fixes the problem more often than not.
If the connection still fails, try connecting from a different device to rule out a client-side problem. For a broader walkthrough of remote access options, see our guide on Raspberry Pi remote desktop.
Step 4: Connecting to Your Raspberry Pi Over the Internet
Set Up Port Forwarding
To set up port forwarding, log in to your router’s admin panel (usually via a web browser) using the router’s IP address and your credentials. Navigate to the port forwarding or virtual server settings, which may be under the advanced or security sections. Create a new port forwarding rule, specifying the Raspberry Pi’s local IP address and the VNC port (default: 5900). Some routers require you to enter both the external and internal port numbers. Save the settings and restart your router if prompted. This forwards incoming VNC traffic to your Raspberry Pi, allowing remote access from outside your local network. If you have a firewall enabled on your router, ensure it allows incoming connections on the VNC port. For added security, consider changing the default VNC port to a less common one and enabling SSH for secure tunneling when accessing your Pi remotely over the internet.
Configure Dynamic DNS
To access your Raspberry Pi using a domain name instead of an IP address, consider setting up a dynamic DNS service. This is especially useful if your Pi’s IP changes frequently. Services like No-IP, Dynu, or DuckDNS provide free dynamic DNS for personal use.
First, create an account with a dynamic DNS provider and set up a domain name that points to your Pi’s current IP address. Then, install the provider’s update client on your Pi using the command line. This client will periodically check your Pi’s IP and update the DNS records if it changes.
Once the dynamic DNS is configured, you can use the domain name you set up to access your Pi via VNC from anywhere, without needing to know its current IP address. This makes connecting to your Pi more convenient and reliable, especially for remote access or when sharing your Pi’s VNC connection with others.
Tools and materials
Before you start the VNC setup, gather everything in one place. Nothing here is exotic, and most of it is probably sitting on your desk already.
Hardware
- A Raspberry Pi with network access. A Pi 4 Model B, Pi 5, or Pi Zero 2 W all work fine. Older boards run VNC too, just more slowly.
- A microSD card (16 GB or larger) with Raspberry Pi OS already installed and booted at least once.
- A reliable power supply rated for your model. Undervoltage causes laggy, dropping remote sessions that look like VNC problems but aren’t.
- An Ethernet cable or Wi-Fi credentials. Wired is steadier if your router is nearby.
Temporary access
You need a way to reach the Pi once, to switch VNC on. That means either a monitor, keyboard, and mouse, or a headless setup where you’ve enabled SSH ahead of time. If you’re going without a monitor, set up SSH when you flash the card. If that’s the route you’re taking, a Raspberry Pi headless installation without a monitor keeps the first connection straightforward.
Software and info to have ready
- A VNC viewer app on the computer or phone you’ll connect from.
- The Pi’s IP address or hostname. Run
hostname -Iin a terminal to find it. - Your Pi username and password.
- Your router login, in case you need to reserve a fixed IP address.
Got all of that? Good. The setup itself takes about ten minutes.
Safety Warnings
Remote access to a Raspberry Pi is convenient, but exposing it to the internet changes your risk profile. Read these warnings before you follow the steps above, and stop if any of them describe your setup.
Risks to understand first
- Default credentials are the biggest hole. If your Pi still uses the default username and password, change it before enabling VNC or forwarding any ports. Automated scanners find open remote desktop services within hours.
- Never expose VNC directly to the internet. Forwarding the VNC port on your router, especially after setting up dynamic DNS, invites brute-force attempts. Use a VPN or an SSH tunnel instead.
- Unencrypted sessions leak data. Plain VNC over public Wi-Fi can reveal what’s on your screen and, in some configurations, what you type.
Protect your Pi and your data
- Back up your microSD card before changing system settings. A bad edit to a config file can leave the Pi unable to boot.
- Use a strong, unique password of at least 12 characters, and keep the OS updated with
sudo apt update && sudo apt full-upgrade. - Power the Pi with an official or properly rated supply. Undervoltage causes freezes that look like remote desktop failures.
Stop conditions
Stop and disable remote access if you see logins you don’t recognize, unexpected reboots, or a sudden spike in CPU use. Run sudo systemctl disable vncserver-x11-serviced to switch VNC off, then change every password on the device before turning it back on.
Conclusion
Setting up VNC on your Raspberry Pi opens up a world of possibilities for remote access and control. By following the steps outlined in this guide, you can easily configure your Pi for VNC and connect to it from anywhere using another computer, tablet, or smartphone. VNC is a powerful tool that allows you to use your Raspberry Pi’s desktop environment remotely, making it ideal for headless setups, remote troubleshooting, or accessing your Pi projects on the go.
With VNC enabled, you can run applications, manage files, and interact with your Raspberry Pi as if you were sitting right in front of it. This flexibility is particularly useful for educators, hobbyists, and tech enthusiasts who want to work on their Pi projects remotely or collaborate with others. Whether you’re a beginner or an experienced user, setting up VNC on your Raspberry Pi is a valuable skill that can enhance your projects and streamline your workflow. So why not give it a try and unlock the full potential of your Raspberry Pi?


