When I run Xvfb server directly, x11vnc can attach to the display fine as per Wikipedia page.

However I'd like to achieve the same by running the X app using xvfb-run.

Here is my attempt (to run wine explorer as an example):

$ xvfb-run -l --server-args="-screen 0 1024x768x24" wine explorer
$ ps x | grep Xvfb
19536 pts/2    Sl     0:00 Xvfb :99 -screen 0 1024x768x24 -auth /tmp/xvfb-run.nJKLnF/Xauthority

However when I'm trying to run x11vnc it fails:

$ x11vnc -display :99.0 -usepw -forever -autoport 5900
24/11/2016 22:51:29 XOpenDisplay(":99.0") failed.
24/11/2016 22:51:29 Trying again with XAUTHLOCALHOSTNAME=localhost ...
No protocol specified

24/11/2016 22:51:29 ***************************************
24/11/2016 22:51:29 *** XOpenDisplay failed (:99.0)

*** x11vnc was unable to open the X DISPLAY: ":99.0", it cannot continue.
*** There may be "Xlib:" error messages above with details about the failure.

I also tried the command suggested from x11vnc troubleshooting page, but with no luck.

How can I run X command via xvfb-run so it display can be accessible by x11vnc?


As you can see in your ps output, the Xvfb server is run with parameter -auth followed by the name of a temporary file. To connect to this server you therefore need to provide a copy of the MIT-MAGIC-COOKIE that is held in this file. Usually this is done by simply setting the XAUTHORITY variable in the environment of the command, eg

XAUTHORITY=/tmp/xvfb-run.nJKLnF/Xauthority x11vnc ...

To simplify, your xvfb-run script might accept an option -f followed by the name of a file of your choice in which to save the cookie.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.