x11vnc cannot connect to the X display
XOpenDisplay failedShort 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.
Fix it fast
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 -listdpy2Match what you see, then jump to its fix
- 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
The 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
-listdpy lists nothing, and nobody is logged in to a desktopThere is no X session on the machine at allFix
- 1
What does the error look like?
XOpenDisplay failedx11vnc 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 -finddpy2Fix
Pass the display that -finddpy or -listdpy reported.
x11vnc -display :03Verify
x11vnc prints the VNC port it listens on instead of exiting.
ss -ltnp | grep x11vncConfirmed by manpages.ubuntu.com
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 -findauth2Fix
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 guess3Verify
The connection is accepted and a VNC viewer shows the screen.
ss -ltnp | grep x11vncConfirmed by manpages.ubuntu.com
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 -finddpy2Fix
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 -create3Verify
A VNC viewer connects to a session you can use.
ss -ltnp | grep x11vncConfirmed by manpages.ubuntu.com
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 fixServers
Ansible hangs, then times out waiting for the sudo prompt
a playbook using become seems to hang
Ansible ran sudo on the target and never saw the answer it expected.
3 causes, each with a fixServers
Apache on Ubuntu returns 404 Not Found for my site
The requested URL was not found on this server.
On Ubuntu a 404 from Apache usually means the request maps to a path that has no file.
3 causes, each with a fixServers
Apache returns 504 Gateway Timeout when PHP takes too long
Quick requests work, slow ones end in a 504 after a fixed wait
A 504 from Apache means the backend did not answer within the proxy timeout.
2 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
Apache warns that a ${VAR} config variable is not defined
${VAR} left unchanged in the configuration, with a warning in the error log
Apache expands ${VAR} from Define or from the shell environment that exists when the server starts.
3 causes, each with a fix