Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

x11vnc cannot connect to the X display

ErrorXOpenDisplay failed

Short answer

x11vnc must open an X display it is allowed to use. List what it can find with -listdpy, then pass the right -display and an auth file with -auth guess. On a server with no desktop session, let x11vnc make one with -create.

  • Applies to x11vnc (Ubuntu 24.04 package), Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask x11vnc which X displays this user can open. If it lists one, use it as -display. If the list is empty, the cause is access or a missing X server.

    x11vnc -listdpy
  2. 2Match what you see, then jump to its fix

    1. 1-listdpy shows a display such as :1 while you started x11vnc with -display :0 (or without -display, from an SSH shell)Wrong or missing display nameFix
    2. 2The display exists in a desktop session, but you run x11vnc as another user, as root, or from a servicex11vnc is not allowed to use the display (X authority file)Fix
    3. 3-listdpy lists nothing, and nobody is logged in to a desktopThere is no X session on the machine at allFix

What does the error look like?

  • XOpenDisplay failed
  • x11vnc exits at start and no VNC port is opened

Cause 1 of 3

Wrong or missing display name

1Check

-display is the same as the DISPLAY variable, usually :0, and the X server must run on the same machine. Over SSH there is no DISPLAY, so x11vnc has nothing to open unless you give one.

echo "$DISPLAY"
x11vnc -finddpy

2Fix

Pass the display that -finddpy or -listdpy reported.

x11vnc -display :0

3Verify

x11vnc prints the VNC port it listens on instead of exiting.

ss -ltnp | grep x11vnc

Confirmed by manpages.ubuntu.com

Did this fix it?

Cause 2 of 3

x11vnc is not allowed to use the display (X authority file)

1Check

Access to an X server is controlled by an authority file (XAUTHORITY). x11vnc can search for the right one itself, and -findauth prints what it would use.

x11vnc -display :0 -findauth

2Fix

Let x11vnc find the file. For the login screen, run it as root and have it look for the greeter's file too.

x11vnc -display :0 -auth guess

# login screen (GDM, XDM, KDM), as root:
sudo x11vnc -display :0 -env FD_XDM=1 -auth guess

3Verify

The connection is accepted and a VNC viewer shows the screen.

ss -ltnp | grep x11vnc

Confirmed by manpages.ubuntu.com

Did this fix it?

Cause 3 of 3

There is no X session on the machine at all

1Check

A headless server has no display to share. x11vnc has a mode that looks for one and, if none exists, creates a virtual one.

x11vnc -finddpy

2Fix

Start x11vnc with -create. It tries to find the user's display first and creates a virtual session if there is none (the same as -display WAIT:cmd=FINDCREATEDISPLAY-Xvfb).

x11vnc -create

3Verify

A VNC viewer connects to a session you can use.

ss -ltnp | grep x11vnc

Confirmed by manpages.ubuntu.com

Did this fix it?

How do I stop it coming back?

  • Keep a VNC port off the public internet. -localhost limits x11vnc to local connections, so reach it through an SSH tunnel.
  • Use -auth guess in the service file, not a hard-coded authority path that changes at each login.
  • Run -listdpy first when anything about the session changed.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Servers

dnf cannot install MySQL on Amazon Linux 2023

dnf cannot find a mysql-server package on Amazon Linux 2023

Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.