x11vnc was unable to open the X DISPLAY

October 7, 2010

Having trouble getting x11vnc working?

Here’s the error:

root@qaubutu:/etc/X11/gdm# x11vnc -forever -usepw -httpdir /usr/share/vnc-java/ -httpport 5800 -auth /var/gdm/:0.Xauth
06/10/2010 16:28:21 ***************************************
06/10/2010 16:28:21 *** XOpenDisplay failed (:0)

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

You must run this command to figure out the right path for gdm:

root@qaubutu:/etc/X11/gdm# ps wwwaux | grep auth

output (text in red is the info you need):
root 1791 0.0 0.1 3004 748 pts/5 R+ 16:29 0:00 grep auth
root 6134 0.0 3.1 37500 12148 tty7 Ss+ 2009 178:10 /usr/bin/X :0 -br -audit 0 -auth /var/lib/gdm/:0.Xauth -nolisten tcp vt7

The correct command with fixed syntax:
root@qaubutu:/etc/X11/gdm# x11vnc -forever -usepw -httpdir /usr/share/vnc-java/ -httpport 5800 -auth /var/lib/gdm/:0.Xauth

And for copying and pasting purposes:

root@qaubutu:/etc/X11/gdm# x11vnc -forever -usepw -httpdir /usr/share/vnc-java/ -httpport 5800 -auth /var/lib/gdm/:0.Xauth