Learning Center
Ubuntu

How to Install and Configure VNC on Ubuntu

27 Jan 2026
Hostman Team
Hostman Team

Various protocols are used to organize remote access to computers and servers. For Windows, the native protocol is RDP, while for Unix/Linux, we mostly use SSH. However, there is another option: VNC. This guide will cover installing a VNC server, specifically the TightVNC implementation, on Ubuntu 22.04, and explain how to connect to the VNC server. Before that, we'd like to recommend you check the instruction on how to deploy server on Ubuntu.

And if you’re looking for a reliable, high-performance, and budget-friendly solution for your workflows, Hostman has you covered with Linux VPS Hosting options, including Debian VPS, Ubuntu VPS, and VPS CentOS.

What is VNC?
Copy link

VNC (Virtual Network Computing) is a system for remote access to computers and servers based on the RFB (Remote FrameBuffer) protocol. Using a network connection, it transmits keyboard inputs and mouse movements from one machine to another. VNC is platform-independent and a cross-platform solution.

VNC consists of a server and a client: the server provides access to the device's screen, and the client displays the server's screen. We will use TightVNC, which is open-source, optimized for slow connections, and widely supported by third-party VNC client programs.

VNC vs. RDP
Copy link

While VNC and RDP both provide remote access, there are key differences. RDP is a proprietary protocol developed by Microsoft for Windows, while VNC is cross-platform, running on Windows, Linux/Unix, and macOS. VNC is open-source and free.

RDP transmits a video stream using a capture device, displaying the remote desktop after the connection is initiated. VNC, however, sends pixel data directly. RDP includes built-in encryption and authentication integration with Windows, while VNC requires additional security configuration. RDP also supports device forwarding, file transfers, and peripheral access (e.g., USB drives and printers), while VNC primarily focuses on remote desktop functionality.

Prerequisites
Copy link

To install and configure VNC, you'll need:

  1. A VPS running Ubuntu 22.04.

  2. A VNC client program installed on any operating system, as VNC is cross-platform. Some client programs are listed in the "Connecting to the VNC Server" section.

Installing TightVNC and Xfce
Copy link

First, we'll install the TightVNC server and the Xfce desktop environment, which is lightweight and optimized for TightVNC. The following commands should be run as the root user or a user with sudo privileges.

Update the package list and install the required packages:

apt update && apt -y install xfce4 xfce4-goodies tightvncserver

If you are using UFW, iptables, or another firewall tool, open port 5901 for VNC connections:

For UFW:

ufw allow 5901

You can also temporarily disable UFW for testing:

systemctl stop ufw

For iptables:

To allow incoming connections on port 5901:

iptables -I INPUT -p tcp --dport 5901 -j ACCEPT

To allow outgoing connections on port 5901:

iptables -I OUTPUT -p tcp --sport 5901 -j ACCEPT

Configuring the TightVNC Server
Copy link

Once TightVNC is installed, we need to configure it.

  1. Set the password for accessing the remote host by running the vncserver command:
vncserver

The password should be between 6 and 8 characters. If it's longer, TightVNC will truncate it to 8 characters.

You will be prompted to set a view-only password (optional). This password allows users to view the remote screen without controlling it. To set this password, type y and provide a password. If you don't need this feature, enter n.

After running vncserver, you’ll see the following output:

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/[hostname]:1.log
  1. Stop the VNC server to configure it further:
vncserver -kill :1
  1. Backup the default configuration file before editing it:
cp ~/.vnc/xstartup ~/.vnc/xstartup.bak
  1. Open the configuration file in a text editor:
nano /root/.vnc/xstartup

Image12

Add the following line to the end of the file:

startxfce4

Image7

Save the changes and exit.

  1. Restart the VNC server:
vncserver

Managing TightVNC with systemd
Copy link

We’ll create a systemd service to manage TightVNC more easily.

Create a new unit file:

nano /etc/systemd/system/vncserver.service

Add the following content:

[Unit]
   Description=TightVNC server
   After=syslog.target network.target
[Service]
   Type=forking
   User=root
   PAMName=login
   PIDFile=/root/.vnc/%H:1.pid
   ExecStartPre=-/usr/bin/vncserver -kill :1 > /dev/null 2>&1
   ExecStart=/usr/bin/vncserver
   ExecStop=/usr/bin/vncserver -kill :1
[Install]
   WantedBy=multi-user.target

Image15 (1)

Reload the systemd daemon:

systemctl daemon-reload

Enable the service to start on boot:

systemctl enable --now vncserver

Check the VNC server status:

systemctl status vncserver

If the status shows "active (running)," the server is running successfully.

Connecting to the VNC Server
Copy link

There are various VNC client programs, both free and paid. Examples include UltraVNC and TightVNC Viewer for Windows, Remmina for Linux, and RealVNC for macOS.

For example, to connect using TightVNC Viewer on Windows:

  1. Enter the server's IP address and port in the format:
IP_address::port

Note: TightVNC requires :: to separate the IP and port, whereas other programs may use :.

2ddfdc03 D1e0 4149 89ce 6346819d61fe

  1. When prompted, enter the password you set earlier.

A7fc75a4 4095 40c9 Affc Cfb8852a0672

  1. Once authenticated, the remote desktop will appear.

Image14 (1)

TightVNC Viewer allows saving sessions for quick connections. Click the save icon, provide a name, and save the file with a .vnc extension. You can also save the password for easier future access.

93b8f355 87ca 4886 8a24 713527400066

For increased security, it's recommended to use SSH tunnels when connecting over VNC.

Conclusion
Copy link

VNC is a convenient system for remote access, often used for technical support or server maintenance. This guide provides a step-by-step process for installing and configuring TightVNC on an Ubuntu server and connecting to it from a remote machine. With simple setup steps, you can have a VNC server running in no time. Especially, if you use our low-latency US based VPS.

If you want to know more about Hostman server solutions, you can check the most affordable VPS Servers

Frequently Asked Questions (FAQ)
Copy link

What is the best VNC server for Linux? 
Copy link

For most users, TigerVNC or TightVNC are the best choices.

  • TigerVNC: Known for speed and performance.

  • TightVNC: Highly reliable and lightweight, great for low-bandwidth connections.

  • RealVNC: Good for enterprise features but less common for open-source home labs.

How do I install and configure VNC on Ubuntu? 
Copy link

The general process involves three steps:

  1. Install the Desktop: Ensure you have a desktop environment (like XFCE or GNOME) installed: sudo apt install xfce4.

  2. Install VNC Server: Run sudo apt install tigervnc-standalone-server.

  3. Configure: Run vncserver to set your password and generate the initial config files, then edit ~/.vnc/xstartup to tell VNC which desktop to launch.

Is VNC better than RDP? 
Copy link

It depends on the use case.

  • RDP (Remote Desktop Protocol): Generally offers better performance, audio support, and a smoother experience over slower networks because it transmits semantic instructions rather than just pixels.

  • VNC (Virtual Network Computing): Is platform-independent (works on Mac, Linux, Windows, Android equally well) and uses a simpler "pixel-based" protocol, making it easier to troubleshoot across different systems.

How do I check the status of VNC server in Ubuntu? 
Copy link

If you are running it manually, use: vncserver -list This will show all active display numbers and their process IDs. If you set it up as a systemd service, run: sudo systemctl status vncserver@1.service (adjusting the number to match your display ID).

How do I find my VNC server address? 
Copy link

The address is your server's IP address followed by the port number.

  1. Find your IP: ip a (e.g., 192.168.1.50).

  2. Find your Port: Add 5900 to your display number. (Display :1 = Port 5901).

  3. Address: 192.168.1.50:5901.

Why is my VNC screen blank or grey?
Copy link

This is the most common VNC error. It means the xstartup script is missing or has the wrong permissions. Ensure the file is executable (chmod +x ~/.vnc/xstartup) and contains the correct command to start your specific desktop session (e.g., startxfce4).