You can remote access your Raspberry Pi desktop via VNC from anywhere without port forwarding. Enable wayvnc (built into Raspberry Pi OS Desktop) or TigerVNC (for Raspberry Pi OS Lite), keep it listening on 127.0.0.1, and run the SocketXP agent, which makes an outbound TLS tunnel. Then open the Pi desktop directly in your web browser with one click in the SocketXP Portal, or connect a native viewer such as RealVNC Viewer, TigerVNC Viewer, Remmina or macOS Screen Sharing. This works behind home routers, corporate firewalls, CGNAT, 4G/5G and Starlink.
This guide is specific to Raspberry Pi. For other boards such as NVIDIA Jetson and industrial gateways, or for x11vnc and fleet-wide setups, see the general guide: How to Remote Access IoT Devices via VNC. For every Pi access method, see Raspberry Pi remote access.
- Raspberry Pi OS Desktop (Bookworm/Trixie): enable the built-in wayvnc with
sudo raspi-config nonint do_vnc 0. It listens on port 5900. - Raspberry Pi OS Lite: install XFCE + TigerVNC and enable
tigervncserver@:1. It listens on port 5901. - No port forwarding:
sudo socketxp login <token>plus a one-line tunnel config on the Pi. - Zero-install browser access: click VNC next to your Pi in the SocketXP Portal to open its desktop in a browser tab.
- Or use a native viewer through IoT slave mode: RealVNC Viewer, TigerVNC Viewer, Remmina or macOS Screen Sharing on
localhost:10111.
Why Remote VNC to a Raspberry Pi Is Hard
VNC listens on TCP port 5900 + display number: 5900 for the physical screen (wayvnc), 5901 for a TigerVNC virtual desktop on display :1. Reaching that port from the internet normally means forwarding it on your router to the Pi’s local IP. That approach:
- Is impossible when your ISP uses CGNAT, because your router has no public IP
- Exposes VNC to the open internet, where port scanners and brute-force bots are routine
- Breaks whenever your public IP changes, unless you add dynamic DNS
- Needs firewall changes you often can’t make in corporate, campus or customer networks
SocketXP reverses the connection. The agent on the Pi dials out to the SocketXP Cloud Gateway over TLS on port 443, which is almost never blocked. Your VNC session then flows back through that existing tunnel, either to your browser or to a VNC viewer on your computer, with no inbound firewall hole. See how NAT routers and firewalls block inbound access for the background.
Which VNC Server Should You Use on Raspberry Pi?
| Your Pi image | VNC server | Shows | Port |
|---|---|---|---|
| Raspberry Pi OS Desktop, Bookworm or Trixie (Wayland) | wayvnc, pre-installed | The real Pi desktop | 5900 |
| Raspberry Pi OS Lite (no desktop) | TigerVNC + XFCE | A virtual desktop | 5901 |
| Raspberry Pi OS Bullseye or older (X11) | RealVNC Server, pre-installed | The real Pi desktop | 5900 |
Older tutorials tell you to install TightVNC Server. It’s effectively unmaintained, so use TigerVNC instead. x11vnc and RealVNC Server don’t work with the Wayland desktop on current Raspberry Pi OS.
Step 1: Enable a VNC Server on Your Raspberry Pi
Update the package index first:
sudo apt update
Option A: wayvnc (Raspberry Pi OS Desktop, Bookworm and later)
Enable the built-in wayvnc server:
sudo raspi-config nonint do_vnc 0
Or use the menu: sudo raspi-config → Interface Options → VNC → Yes.
wayvnc signs you in with your Raspberry Pi username and password. If the Pi has no monitor attached, set a size for its virtual display under Display Options → VNC Resolution in raspi-config, then reboot.
Optional hardening: SocketXP connects to wayvnc over 127.0.0.1, so you can stop wayvnc listening on your LAN. Edit /etc/wayvnc/config, set the line below, then restart:
address=127.0.0.1
sudo systemctl restart wayvnc ss -tlnp | grep 5900
Your tunnel target is port 5900.
Option B: TigerVNC + XFCE (Raspberry Pi OS Lite)
Install a lightweight desktop and TigerVNC. dbus-x11 is needed for the XFCE session to start:
sudo apt install -y tigervnc-standalone-server xfce4 xfce4-terminal dbus-x11
As your normal user (not root), set the VNC password:
vncpasswd
Create the TigerVNC config file: ~/.config/tigervnc/config on TigerVNC 1.14 and later, or ~/.vnc/config on older versions:
session=xfce geometry=1600x900 localhost alwaysshared
The localhost line keeps VNC off your LAN; only the SocketXP agent on the Pi can reach it. Map display :1 to your user and enable the service so the desktop starts on every boot:
echo ":1=$USER" | sudo tee -a /etc/tigervnc/vncserver.users sudo systemctl enable --now tigervncserver@:1.service ss -tlnp | grep 5901
Your tunnel target is port 5901. On a Pi Zero 2 W or other 512 MB board, keep the resolution modest; XFCE runs fine, but a full browser inside the session will be slow.
Legacy: RealVNC Server (Bullseye and older)
On older X11 images, RealVNC Server is pre-installed. Enable it with sudo raspi-config → Interface Options → VNC, or with sudo systemctl enable --now vncserver-x11-serviced. It listens on port 5900. If you can, upgrade to a current Raspberry Pi OS image and use wayvnc.
Step 2: Install the SocketXP Agent on the Raspberry Pi
SocketXP is an IoT remote access and device management platform that creates secure SSL/TLS tunnels to devices behind NAT routers, firewalls or CGNAT, with no router changes.
Follow the download and install instructions. The agent is available for arm (32-bit: Pi Zero, Pi 2, Pi 3 on 32-bit OS) and arm64 (64-bit: Pi 3, Pi 4, Pi 5 on 64-bit OS).
Get your authentication token from the SocketXP Portal:

Log in. This registers the Pi and gives it a Device ID:
sudo socketxp login <your-auth-token>
Create /etc/socketxp/config.json with the VNC port: 5900 for wayvnc, 5901 for TigerVNC. Adding SSH gives you a fallback way in if the desktop ever fails:
{
"tunnels": [
{
"destination": "tcp://127.0.0.1:5900"
},
{
"destination": "tcp://127.0.0.1:22"
}
]
}Install and start the agent as a systemd service so the tunnel reconnects after reboots, power cuts and network drops:
sudo socketxp service install --config /etc/socketxp/config.json sudo systemctl daemon-reload sudo systemctl enable socketxp sudo systemctl start socketxp
Your Pi now shows as online in the Devices section of the SocketXP Portal.

Security note: SocketXP doesn’t create a publicly reachable TCP endpoint. The tunnel is private and can only be used from the SocketXP Portal or by the SocketXP agent in slave mode with your auth token. Port scanners can’t find or reach your VNC port.
Step 3: Connect to the Raspberry Pi Desktop
You can open the Pi’s desktop in two ways. Both use the same outbound-only tunnel, so neither one opens a port to the public internet:
| Method 1: Web browser (SocketXP Portal) | Method 2: Native VNC client (IoT slave mode) | |
|---|---|---|
| Software on your computer | None, just a browser | SocketXP agent + a VNC viewer |
| Works from | Any OS, including Chromebooks, tablets and locked-down work laptops | macOS, Windows, Linux |
| Best for | Quick access from anywhere, helping someone else with their Pi | Daily use, best image quality, viewer features like scaling and clipboard |
Method 1: Open the Pi Desktop in Your Web Browser
- Log in to the SocketXP Portal and open the Devices page.
- Find your Raspberry Pi (it should show as online).
- Click the VNC button next to it.
- A VNC Login dialog opens in the browser. Enter the VNC port (5900 for wayvnc, 5901 for TigerVNC), then your Pi username and password (wayvnc) or just your VNC password (TigerVNC). Click Connect.
The Pi desktop opens in a browser tab, the same way the SocketXP web SSH terminal works. You don’t need to install a viewer or VPN client, and the session runs over HTTPS.


Method 2: Use a Native VNC Client via IoT Slave Mode
If you prefer a desktop VNC viewer, run the SocketXP agent in IoT slave mode on your computer. It opens a private local port that forwards to the Pi’s VNC server through the tunnel; only your own computer can reach it. See the IoT slave mode documentation.
macOS or Linux:
socketxp connect tcp://localhost:10111 --iot-slave --peer-device-id "<device-id>" --peer-device-port 5900 --authtoken <your-auth-token>
Windows (PowerShell):
.\socketxp.exe connect tcp://localhost:10111 --iot-slave --peer-device-id "<device-id>" --peer-device-port 5900 --authtoken <your-auth-token>
You should see:
Listening for TCP connections at: Local URL -> tcp://localhost:10111
- Use
--peer-device-port 5901if the Pi runs TigerVNC. 10111is any free port on your computer. Avoid5900on a Mac, because macOS uses it for its own Screen Sharing service.- Find your Pi’s Device ID in the SocketXP Portal under Devices.
Now point any VNC viewer at localhost port 10111:
RealVNC Viewer (Windows, macOS, Linux)
Enter localhost:10111 in the address bar and press Enter. RealVNC Viewer supports wayvnc’s encrypted login, so it’s the safest choice for Raspberry Pi OS Desktop. Sign in with your Pi username and password.

TigerVNC Viewer (Windows, macOS, Linux)
Connect to:
localhost::10111
The double colon matters in TigerVNC and TightVNC Viewer: host::port means a TCP port, while host:N means display number N (port 5900+N).
macOS Screen Sharing (built in)
In Finder choose Go → Connect to Server (⌘K), enter vnc://localhost:10111 and click Connect. This works well with TigerVNC on Raspberry Pi OS Lite.
Linux: Remmina
Create a new connection with the VNC protocol and server localhost:10111.
Performance Tips for Raspberry Pi VNC
- Match the resolution to the job. 1280x720 is plenty for configuration work and much lighter on cellular links.
- On TigerVNC, add
depth=16to the config to roughly halve the pixel data. - Leave your viewer on automatic quality (TigerVNC Auto select, RealVNC Automatic) so it adapts to the link.
- Prefer a wired or 5 GHz connection on the Pi for smooth desktop use; a congested 2.4 GHz link is the most common cause of lag.
- Don’t need the real screen? RDP via xrdp often feels faster for remote-only sessions.
Troubleshooting Raspberry Pi VNC
| Symptom | Likely cause | Fix |
|---|---|---|
| Black screen or very small desktop (headless Pi) | Headless Pi with no display configured | Set Display Options → VNC Resolution in raspi-config and reboot. |
| Grey or black screen (TigerVNC) | XFCE session didn’t start | Install dbus-x11 and check session=xfce. Read the log in ~/.vnc/ or ~/.config/tigervnc/. |
| Authentication fails in macOS Screen Sharing (wayvnc) | Screen Sharing doesn’t support wayvnc’s encrypted login | Use RealVNC Viewer, TigerVNC Viewer or the browser VNC button. |
| Browser VNC session won’t open | VNC not running, or wrong port in config.json | Check ss -tlnp on the Pi and the destination port in /etc/socketxp/config.json. |
| Connection refused in a native viewer | Slave-mode agent not running, or wrong --peer-device-port | Restart the slave-mode command; use 5900 for wayvnc, 5901 for TigerVNC. |
| Viewer connects to the wrong port | Single colon used in TigerVNC/TightVNC Viewer | Use localhost::10111. |
| Pi shows offline in the portal | Agent stopped or no outbound internet | sudo systemctl status socketxp; make sure outbound TCP 443 is allowed. |
| Access lost after reboot | VNC or agent not enabled at boot | systemctl is-enabled for both; re-run systemctl enable. |
How SocketXP Optimizes Raspberry Pi VNC Access
| Concern | Traditional VNC + Port Forwarding | SocketXP VNC Tunnel |
|---|---|---|
| Router configuration | Required (open port 5900/5901 inbound) | Not required |
| Works behind CGNAT | No | Yes |
| Static IP required | Yes (or dynamic DNS) | No |
| VNC port exposed to internet | Yes (visible to port scanners) | No (private tunnel) |
| Encryption layer | Depends on the VNC server | SSL/TLS outer tunnel + VNC auth |
| Access from a browser | No | Yes (VNC button in the portal) |
| Fleet management | Manual per-device setup | Centralized portal, single auth token |
Unlike ngrok, SocketXP is purpose-built for IoT and embedded Linux fleets. The agent runs as a persistent systemd service, survives reboots, reconnects automatically after network disruptions and supports multi-device management from a single portal, without session time limits.
Why SocketXP Outperforms Tailscale and ngrok for Raspberry Pi VNC Access
Engineers evaluating VNC remote access tools for Raspberry Pi often consider Tailscale and ngrok alongside SocketXP. Here’s how they compare for IoT use cases:
| Criterion | ngrok | Tailscale | SocketXP |
|---|---|---|---|
| Architecture | Reverse proxy tunnel | Peer-to-peer mesh VPN | Secure reverse proxy tunnel |
| IoT fleet management | No | No | Yes, centralized device portal |
| Remote OTA updates | No | No | Yes |
| Device health monitoring | No | No | Yes |
| Works behind CGNAT | Yes | Yes (DERP relay) | Yes |
| Session time limits | Yes (free tier) | No | No |
| Scales to 10,000+ devices | Not designed for this | Mesh becomes complex | Native IoT architecture |
| VPN client on access device | No | Required | Not needed (browser), optional (slave mode) |
| Browser-based VNC/SSH | No | No | Yes |
| Resource footprint on Pi | Low | Moderate | Minimal (userspace binary) |
ngrok is a developer tunneling tool optimized for exposing local web servers during development. It isn’t designed for managing IoT device fleets, doesn’t support OTA updates or remote monitoring, imposes session limits on the free tier and has no device management portal. It works well for short-lived developer use but isn’t suited to production IoT deployments.
Tailscale creates a mesh VPN between devices. It’s reliable for small private networks, but it requires a VPN client on every access device and gets operationally complex across thousands of IoT nodes. It has no IoT-specific features: no OTA firmware updates, no device health monitoring, no fleet management portal and no browser-based VNC.
SocketXP is a purpose-built IoT Remote Access and Device Management platform designed to scale to tens of thousands of Raspberry Pi and embedded Linux devices. The agent is a lightweight userspace binary that uses minimal CPU and RAM, so it suits constrained devices like the Raspberry Pi Zero 2 W. Engineers don’t need a VPN client; the SocketXP Portal gives browser-based VNC, SSH and device management from anywhere.
Security and Production Best Practices
- Bind VNC to localhost (
address=127.0.0.1for wayvnc,localhostfor TigerVNC) so the session never crosses your LAN unencrypted. - Use a strong Pi user password. wayvnc signs in with your Linux account. TigerVNC’s classic VNC password only uses its first 8 characters, which is why it should never be exposed outside the tunnel.
- Enforce SSH key authentication on the Pi and disable password-based SSH login.
- Use RBAC in the SocketXP Portal to control which team members can open VNC sessions to which Raspberry Pi devices.
- Rotate your SocketXP auth token periodically and revoke tokens for decommissioned devices immediately.
- Check VNC logs for unexpected sessions:
journalctl -u wayvncorjournalctl -u tigervncserver@:1. - Keep Raspberry Pi OS updated with
sudo apt update && sudo apt full-upgradeto pick up VNC and kernel security fixes.
Conclusion
Remote access to a Raspberry Pi desktop via VNC is a reliable way to handle GUI tasks such as IDEs, dashboards, configuration tools and desktop apps without physical access to the Pi. On current Raspberry Pi OS that means wayvnc on Desktop images and TigerVNC on Lite.
SocketXP’s outbound tunnel makes this work even when the Pi is behind restrictive NAT, CGNAT or corporate firewalls, with no router changes, no static IP and no open inbound ports. You can open the desktop in a browser with one click or use the VNC viewer you already know, and the SocketXP Portal gives you central access control for a whole fleet of Pis.
For SSH, headless setup, web app tunnels and other platform guides, see the Raspberry Pi remote access solution page. For non-Pi devices, see How to Remote Access IoT Devices via VNC.
Frequently Asked Questions
Can I access my Raspberry Pi desktop from a web browser?
Yes. In the SocketXP Portal, click the VNC button next to your Raspberry Pi. A VNC login dialog opens in the browser, and after you sign in the Pi desktop streams into the browser tab. You don't need to install a VNC viewer or any agent on your computer, and no port is opened on your router.
Can I access Raspberry Pi desktop via VNC without port forwarding?
Yes. SocketXP creates a secure outbound SSL/TLS tunnel from the Raspberry Pi to the SocketXP Cloud Gateway. No inbound ports need to be opened on your router. Your VNC session travels through this tunnel, bypassing NAT and firewall restrictions.
Which VNC server does Raspberry Pi OS use now?
wayvnc. Since Raspberry Pi OS Bookworm moved to a Wayland desktop, wayvnc replaced RealVNC Server as the built-in VNC server, and Raspberry Pi OS Trixie keeps it. Enable it with 'sudo raspi-config nonint do_vnc 0'. On Raspberry Pi OS Lite, which has no desktop, install XFCE and TigerVNC instead. RealVNC Server only applies to Bullseye and older X11 images.
Does Raspberry Pi VNC remote access work over cellular or Starlink?
Yes. SocketXP's outbound tunnel works on any internet connection, including 4G/5G cellular and Starlink. Carrier-grade NAT (CGNAT) is not an obstacle because the Pi starts the connection outbound.
Can I use macOS Screen Sharing to connect to a Raspberry Pi?
Yes, macOS Screen Sharing is a standard VNC client: run SocketXP in slave mode and open vnc://localhost:10111. It works well with TigerVNC on Raspberry Pi OS Lite. With wayvnc on Raspberry Pi OS Desktop, Screen Sharing may not support the encrypted authentication wayvnc uses; if it fails, use RealVNC Viewer or TigerVNC Viewer for Mac, or the SocketXP browser VNC button.
Can I use RealVNC Viewer to connect to Raspberry Pi via SocketXP?
Yes. RealVNC Viewer, TigerVNC Viewer, TightVNC Viewer, Remmina and macOS Screen Sharing all work when pointed at the SocketXP slave-mode endpoint on your computer.
How do I get a usable resolution on a headless Raspberry Pi without a monitor?
Run 'sudo raspi-config' and set Display Options > VNC Resolution (for example 1920x1080), then reboot. wayvnc then serves a virtual display at that size. With TigerVNC on Raspberry Pi OS Lite, set geometry=1600x900 in the TigerVNC config file.