---
title: "Xvfb for agent desktops: the options that matter and the defaults that surprise"
description: "Start Xvfb with an explicit screen, for example Xvfb :99 -screen 0 1280x1024x24 -nolisten tcp, rather than relying on defaults. Its documented default depth differs between versions (8 in older manuals, 24 in the X.Org 21.1 manual), and xvfb-run adds its own defaults on top."
url: "https://www.vmforai.com/issue/xvfb-virtual-display-setup/"
site: "VMForAI.com"
author: "VMForAI editors"
published: "2026-11-26"
updated: "2026-11-26"
---

# Xvfb for agent desktops: the options that matter and the defaults that surprise

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

Start Xvfb with an explicit screen, for example Xvfb :99 -screen 0 1280x1024x24 -nolisten tcp, rather than relying on defaults. Its documented default depth differs between versions (8 in older manuals, 24 in the X.Org 21.1 manual), and xvfb-run adds its own defaults on top.

Xvfb is the X Window System's virtual framebuffer server: an X server that draws into memory instead of onto a monitor. For a computer-use agent it is the screen. Getting its few options right decides what the model sees and who else can see it.

## What is Xvfb?

Xvfb is "an X server that can run on machines with no display hardware and no physical input devices", and it "emulates a dumb framebuffer using virtual memory" ([Xvfb manual, Debian bookworm](https://manpages.debian.org/bookworm/xvfb/Xvfb.1.en.html), read 2026-11-26). The manual says it was meant for server testing, and lists other uses, including "providing an unobtrusive way to run applications that don't really need an X server but insist on having one anyway". A desktop agent is a heavier use: it runs ordinary graphical applications on the virtual screen and reads the pixels back.

## Which Xvfb options matter for an agent?

Five options cover almost every agent desktop. The first two are Xvfb's own; the rest are options every X server accepts.

Table: Xvfb and X server options for an agent display

| Option | What it does | Why it matters for an agent |
|---|---|---|
| `-screen 0 WxHxD` | "creates screen screennum and sets its width, height, and depth" | Fixes the size of every screenshot and the range of every click |
| `-fbdir DIR` | Puts the framebuffer in memory-mapped files in DIR | Lets other tools read the screen as a file |
| `-dpi N` | "sets the resolution for all screens, in dots per inch" | Changes how large applications draw text and controls |
| `-nolisten tcp` | Disables TCP/IP connections | Keeps the display local to the machine |
| `-nocursor` | "disable the display of the pointer cursor" | Hides the pointer; most agents want to see it, so leave it out |

Sources: the [Xvfb manual](https://manpages.debian.org/bookworm/xvfb/Xvfb.1.en.html) and the [Xserver manual](https://xorg.freedesktop.org/archive/current/doc/man/man1/Xserver.1.xhtml), read 2026-11-26.

Two options to avoid: `-ac`, which "disables host-based access control mechanisms. Enables access by any host" and comes with the warning "Use with extreme caution" (Xserver manual), and leaving TCP open on a machine other people can reach.

## What is the default screen, and why set it yourself?

The default is one screen of 1280x1024, but the documented depth depends on which manual you read, so always pass `-screen`.

Table: Documented Xvfb defaults

| Source | Default screen |
|---|---|
| Xvfb manual for X.Org server 21.1, Debian bookworm | 1280x1024x24 |
| Xvfb manual in the X.Org documentation archive | 1280x1024x8 |
| xvfb-run, Debian bookworm | `-screen 0 1280x1024x24` passed by the script |

Sources: [Xvfb manual, Debian bookworm](https://manpages.debian.org/bookworm/xvfb/Xvfb.1.en.html), [Xvfb manual, X.Org archive](https://xorg.freedesktop.org/archive/current/doc/man/man1/Xvfb.1.xhtml), [xvfb-run manual](https://manpages.debian.org/bookworm/xvfb/xvfb-run.1.en.html), all read 2026-11-26.

An 8-bit screen has 256 colours, so screenshots taken from it look nothing like a normal desktop. A model trained on ordinary screenshots should be shown a 24-bit screen. Writing `-screen 0 1280x1024x24` (or the size you chose) removes the dependence on the installed version.

## Should I use xvfb-run or start Xvfb myself?

Use xvfb-run for one command that needs a display, and start Xvfb yourself for a desktop that lives for a whole agent session.

xvfb-run is a wrapper script. Its manual gives the defaults: server arguments "-screen 0 1280x1024x24", display number 99, and `-a` to "Try to get a free server number, starting at 99". It creates a temporary X authority file and removes it when the command exits, and it "requires the xauth command to function" (xvfb-run manual, read 2026-11-26). That is ideal for a test or a single tool run:

```
xvfb-run -a -s "-screen 0 1920x1080x24 -nolisten tcp" python3 run_task.py
```

An agent desktop is different: a window manager, a VNC server and the agent all connect to the same display for minutes or hours. Start Xvfb directly, export `DISPLAY`, and start the other programs against it, as in our [Linux desktop setup](https://www.vmforai.com/issue/linux-desktop-for-an-ai-agent/).

## How do I keep the display private?

Keep the display private with three settings: no TCP listener, an authority file, and no `-ac`.

1. `-nolisten tcp` so only local programs can connect.
2. `-auth FILE`, which "specifies a file which contains a collection of authorization records used to authenticate access" (Xserver manual). xvfb-run does this for you.
3. Run Xvfb and the agent as a normal user, not root, so a program on the display cannot write anywhere on the system.

Anything that can connect to the X display can read the screen and inject input, so treat display access like a login.

## How do I read the screen without a viewer?

Read the screen with FFmpeg or from the framebuffer file. FFmpeg's x11grab device "allows one to capture a region of an X11 display" ([FFmpeg devices](https://ffmpeg.org/ffmpeg-devices.html), read 2026-11-26):

```
ffmpeg -y -f x11grab -video_size 1280x1024 -i :99 -frames:v 1 screen.png
```

Or start Xvfb with `-fbdir`, which the manual says sets "the directory in which the memory mapped files containing the framebuffer memory should be created", and view the file with xwud. The X.Org manual's example is `Xvfb -pixdepths 3 27 -fbdir /var/tmp` followed by `xwud -in /var/tmp/Xvfb_screen0` (Xvfb manual, X.Org archive).

## How do I check the display is set up right?

Check the display with three commands before the agent starts:

1. `xdpyinfo -display :99`: xdpyinfo is "a utility for displaying information about an X server" and shows its screens and visuals ([xdpyinfo manual](https://manpages.debian.org/bookworm/x11-utils/xdpyinfo.1.en.html), read 2026-11-26). Confirm the dimensions and depth match your `-screen`.
2. `xdpyinfo -display :99 -ext XTEST`: input tools such as xdotool need the XTEST extension.
3. One screenshot with FFmpeg: it should be the size you set, in full colour.

## What we read for this article

- [Xvfb manual, Debian bookworm (X.Org server 21.1)](https://manpages.debian.org/bookworm/xvfb/Xvfb.1.en.html), read 2026-11-26
- [Xvfb manual, X.Org documentation archive](https://xorg.freedesktop.org/archive/current/doc/man/man1/Xvfb.1.xhtml), read 2026-11-26
- [Xserver manual, X.Org documentation archive](https://xorg.freedesktop.org/archive/current/doc/man/man1/Xserver.1.xhtml), read 2026-11-26
- [xvfb-run manual, Debian bookworm](https://manpages.debian.org/bookworm/xvfb/xvfb-run.1.en.html), read 2026-11-26
- [xdpyinfo manual, Debian bookworm](https://manpages.debian.org/bookworm/x11-utils/xdpyinfo.1.en.html), read 2026-11-26
- [FFmpeg devices](https://ffmpeg.org/ffmpeg-devices.html), read 2026-11-26

## FAQ

### What is the default Xvfb screen size?

1280x1024. The depth depends on the version of the manual you read; Debian bookworm's Xvfb 21.1 manual says 1280x1024x24, while the X.Org archive manual says 1280x1024x8. Set -screen yourself so the question never matters.

### What does xvfb-run do?

It starts Xvfb, creates a temporary X authority file, runs your command with DISPLAY set, and stops the server when the command exits. Its default server arguments are -screen 0 1280x1024x24 and its default display is 99.

### How do I stop other machines from connecting to my Xvfb display?

Add -nolisten tcp, and do not use -ac, which the X server manual says disables host-based access control and should be used with extreme caution.

### Can I see what is on an Xvfb screen without VNC?

Yes. Start Xvfb with -fbdir so the framebuffer is kept in a memory-mapped file, then read it with xwud, or take a screenshot with FFmpeg's x11grab device.
