---
title: "How to watch an agent's desktop in a browser with x11vnc and noVNC"
description: "To watch an agent's desktop in a browser, run x11vnc on its display with a password and -localhost, put websockify and noVNC in front, and reach the page only over a private, authenticated path. Use x11vnc's -viewonly when people should watch but not touch."
url: "https://www.vmforai.com/issue/watch-an-agent-desktop-with-vnc-and-novnc/"
site: "VMForAI.com"
author: "VMForAI editors"
published: "2026-11-26"
updated: "2026-11-26"
---

# How to watch an agent's desktop in a browser with x11vnc and noVNC

VMForAI editors. Published 2026-11-26, updated 2026-11-26.

To watch an agent's desktop in a browser, run x11vnc on its display with a password and -localhost, put websockify and noVNC in front, and reach the page only over a private, authenticated path. Use x11vnc's -viewonly when people should watch but not touch.

Watching an agent's desktop in a browser takes three programs: a VNC server attached to the agent's display, websockify to turn the VNC connection into a WebSocket, and noVNC as the client page. The agent does not need any of them. They are for the people who debug runs, approve risky steps or take over when the agent gets stuck.

## How do the pieces fit together?

The VNC server reads the X display, websockify relays its traffic to the browser, and noVNC draws it.

Table: The viewing chain for an agent desktop

| Piece | Role | Default port |
|---|---|---|
| x11vnc | Serves an existing X display (for example Xvfb's :99) over VNC | 5900, "the default VNC server port" |
| websockify | "translates WebSockets traffic to normal socket traffic" and can serve the web files | Set on the command line; 6080 in noVNC's launcher |
| noVNC | The VNC client that runs in the browser | Served by websockify |

Sources: [x11vnc manual](https://manpages.debian.org/bookworm/x11vnc/x11vnc.1.en.html), [websockify](https://github.com/novnc/websockify) and [noVNC's novnc_proxy script](https://raw.githubusercontent.com/novnc/noVNC/master/utils/novnc_proxy), read 2026-11-26.

noVNC "follows the standard VNC protocol, but unlike other VNC clients it does require WebSockets support". Some servers speak WebSockets themselves; for the rest, the project points to websockify ([noVNC repository](https://github.com/novnc/noVNC), read 2026-11-26).

## Step 1: How do I start x11vnc safely?

Start x11vnc with a stored password, bound to the local machine, and kept running between viewers.

```
mkdir -p ~/.vnc
x11vnc -storepasswd "$VNC_PASSWORD" ~/.vnc/passwd
x11vnc -display :99 -rfbauth ~/.vnc/passwd -localhost -rfbport 5900 -forever -shared
```

What each option does, from the x11vnc manual (read 2026-11-26):

- `-storepasswd pass file`: "Store password pass as the VNC password in the file file. Once the password is stored the program exits."
- `-localhost`: "Basically the same as" allowing only the loopback address, so remote machines cannot connect directly.
- `-forever`: "Keep listening for more connections rather than exiting as soon as the first client(s) disconnect."
- `-shared`: "more than one viewer can connect at the same time (default off)."

The manual says "use of a VNC password (-rfbauth or -passwdfile) is strongly recommended", and also that the `-rfbauth` file "is NOT encrypted, only obscured with a fixed key". Generate a new random password per desktop and keep the file readable only by its owner.

## Step 2: How do I put noVNC in front of it?

Put noVNC in front by running websockify with noVNC's web files and the VNC server as its target.

```
VNC_HOST=localhost
websockify --web /usr/share/novnc 6080 "${VNC_HOST}:5900"
```

`--web DIR` makes websockify serve a directory "on the same port as the proxy" (websockify, read 2026-11-26). The path above is where Debian's `novnc` package installs `vnc.html` ([novnc file list](https://packages.debian.org/bookworm/all/novnc/filelist), read 2026-11-26).

noVNC's own launcher does the same job. Its defaults are port 6080, described as "Default: 6080 (on all interfaces)", and a VNC target on port 5900 of the same machine. The README shows how to keep the web server private by giving `--listen` a loopback address (noVNC repository and novnc_proxy script, read 2026-11-26).

## Step 3: How do I keep the viewer off the internet?

Keep the viewer off the internet by binding it to a private address and reaching it through something that authenticates.

1. **Bind privately.** Give websockify or `--listen` a loopback or private address. In a container, Docker "publishes the port on all interfaces" unless `-p` names a host address ([docker container run](https://docs.docker.com/reference/cli/docker/container/run/), read 2026-11-26).
2. **Encrypt.** websockify accepts `--cert`, `--key` and `--ssl-only`, and the launcher's `--ssl-only` will "Disable non-https connections" (websockify and novnc_proxy, read 2026-11-26).
3. **Authenticate in front.** websockify "can demand authentication for websocket connections" through `--auth-plugin`, and a token plugin lets one websockify reach many desktops by a `token` parameter. A reverse proxy with your own sign-in does the same job.
4. **Expire it.** The launcher's `--idle-timeout` makes the server exit "after SEC seconds if there are no" active connections.

## How do I make it watch-only?

Make the viewer watch-only on the server with x11vnc's `-viewonly`, where "All VNC clients can only watch (default off)" (x11vnc manual). noVNC also has a `view_only` setting, "If the remote session should be in non-interactive mode" ([noVNC embedding settings](https://novnc.com/noVNC/docs/EMBEDDING.html), read 2026-11-26), but a client-side setting can be changed by whoever opens the page. Use the server option for observers and a separate full-access password for the person allowed to take over; x11vnc's `-viewpasswd` provides that split.

## Which noVNC settings help when watching an agent?

These noVNC settings, passed in the page URL, make a viewer easier to use (noVNC embedding settings, read 2026-11-26):

Table: noVNC settings for watching an agent

| Setting | What it does |
|---|---|
| `autoconnect` | "Automatically connect as soon as the page has finished loading." |
| `reconnect` | Reconnects if the connection drops, useful when a desktop restarts between tasks |
| `view_only` | "non-interactive mode" in the client |
| `resize` | `off`, `scale` or `remote`; use `scale` so the viewer never changes the agent's screen size |
| `quality`, `compression` | JPEG quality and compression level, 0 to 9 |
| `password` | The VNC password; the page notes the fragment form (after `#`) "is not sent to the server" |

Avoid `resize=remote` on agent desktops: it asks the server to change the screen size to fit the browser window, and the agent's coordinates depend on that size. See [screen resolution and DPI for computer-use agents](https://www.vmforai.com/issue/screen-resolution-and-dpi-for-computer-use-agents/).

## What we read for this article

- [x11vnc manual, Debian bookworm](https://manpages.debian.org/bookworm/x11vnc/x11vnc.1.en.html), read 2026-11-26
- [noVNC repository](https://github.com/novnc/noVNC), read 2026-11-26
- [noVNC novnc_proxy script](https://raw.githubusercontent.com/novnc/noVNC/master/utils/novnc_proxy), read 2026-11-26
- [noVNC embedding settings](https://novnc.com/noVNC/docs/EMBEDDING.html), read 2026-11-26
- [websockify](https://github.com/novnc/websockify), read 2026-11-26
- [novnc file list, Debian bookworm](https://packages.debian.org/bookworm/all/novnc/filelist), read 2026-11-26
- [docker container run](https://docs.docker.com/reference/cli/docker/container/run/), read 2026-11-26

## FAQ

### What is noVNC?

noVNC is, in its project's words, both an HTML VNC client JavaScript library and an application built on top of that library. It runs in the browser and needs a WebSockets connection, which websockify provides for VNC servers that do not speak WebSockets.

### What port does noVNC use?

The novnc_proxy launch script listens on 6080 by default, on all interfaces, and proxies to a VNC server on port 5900 of the same machine. Change both with --listen and --vnc.

### How do I make the viewer watch-only?

Start x11vnc with -viewonly, so all VNC clients can only watch, or open noVNC with the view_only setting. The server-side option is stronger, because it does not depend on the client.

### Is the x11vnc password file encrypted?

No. The x11vnc manual says the -rfbauth file is not encrypted, only obscured with a fixed key. Protect it with file permissions and keep the VNC port off the network.
