Enabling VNC on your Pi

Accessing your Raspberry Pi remotely from your network via VNC is super simple and can save you form many cabling issues allowing you to run headless but still use the desktop GUI.

Enabling VNC on your Pi
Photo by Sigmund / Unsplash

Here’s an easy one for you but super useful if you want remote access to your desktop from your network. We are going to use something called VNC which gives you Remote Desktop access over the network via a client so you can use your Raspberry Pi without a monitor, keyboard or mouse plugged in.

If you want access from outside your network, make sure you subscribe as there’s a post coming next week you don’t want to miss!

Enabling VNC

Open a terminal on your Pi (or ssh into it if it’s headless) and run the following command:

sudo raspi-config

Now select the Interface Options menu selection (number 3)

the raspberry pi config menu

Once you’ve opened this select the Enable/Disable VNC option.

Enable VNC in the raspi-config settings

Make sure to confirm you want to install and enable this then once it’s complete follow the prompts and exit the menu.

Almost there!

So you’re not quite finished. Once you install wayvnc the program that is the VNC server is set by default to only accept IPv6 traffic. If you want connect to it from an IPv4 address (eg 192.168.0.10) you need to change the configuration and restart the service.

In your terminal run the following command (you can choose a different editor to vim)

sudo vi /etc/wayvnc/config

You want to make it look like the following: you are adding address=0.0.0.0

and removing

address=::

use_relative_paths=true
address=0.0.0.0
enable_auth=true
enable_pam=true
private_key_file=tls_key.pem
certificate_file=tls_cert.pem
rsa_private_key_file=rsa_key.pem

Save the file and get ready to restart wayvnc.

💡
To save and exit from vi/vim press esc :wq the hit enter

Now let’s restart wayvnc.

sudo systemctl restart wayvnc

If you want to check it’s running, you can use the command below.

sudo systemctl status wayvnc

You should get some output like the following below:

Output of the systemctl status wayvnc command

Connecting

Now to connect to your Pi you need to go to your host machine and install a client.

I’d recommend something like remmina for Linux desktops (https://remmina.org).

Or if you’re using windows or macOS, realVNC viewer (https://www.realvnc.com/en/connect/download/viewer/)

There’s also realVNC for iOS and Android devices:

‎RealVNC Viewer: Remote Desktop
‎RealVNC® Viewer from RealVNC® gives you instant remote access to your Mac, Windows and Linux computers from anywhere in the world. You can view your computer’s desktop, and control its mouse and keyboard as though you were sitting down in front of it. Download RealVNC Connect to each computer you w…
RealVNC Viewer: Remote Desktop - Apps on Google Play
Remotely control a desktop anywhere in the world from your Android device!

Once installed you’ll need to enter your IP or Hostname of your Pi and the default port is 5900. You’ll also need to enter your username and password to authenticate.

Connection from iOS and RealVNC

Now you can connect easily to your Pi across your network and play to your heart’s content!

Conclusion

This is great for accessing your Pi on your local network and running it in headless mode. It’ll save you a ton of space not having to have a monitor, keyboard and mouse connected to it or some form of KVM switch (keyboard, video, mouse). It doesn’t solve the problem of remote access from outside your network but I have a post coming on that soon, so please subscribe!

Pro’s

  • Simple install and setup
  • Works with many different clients
  • Saves you space (or enables you to buy a rack cabinet to be uber geeky, like me)

Con’s

  • I wouldn’t recommend opening this up on your router for security reasons
  • Defaults to IPv6 only
  • You may have to play with client settings to get the best quality screen share

PiSource Score

Easy of Setup Features Ease of Use Extendability Total
8 5 7 n/a 20/30