Recently I had to debug an issue with Xvfb server. It was hard to debug, because I was not able to “see” what was going on.
I was able to reproduce and fix one of the issues by mimicking the build server in a Vagrant box. When I tried the fix on the build server, however, something else was wrong. I was able to isolate and resolve the final issue, by getting a VNC server to connect to Xvfb virtual window, by taking the following steps.
On the remote server
- Run Xvfb server:
Xvfb :99 - Install and run x11vnc and point it to the same window
x11vnc -display :99. Note this will output the port thatx11vncis running on, in my case it was5900.
On the local machine
- Forward remote port via SSH to local port:
ssh -p 2222 vagrant@127.0.0.1 -L 5900:127.0.0.1:5900 -N,
where-pis the port SSH is running on, usually it’s 22 and can be omitted.vagrant@127.0.0.1is a username and IP of the remote machine. In my case it’s the localhost IP, but with a real server it would be different.5900is the port, outputted whenx11vncwas started. - Install vncviewer (i.e.
brew install tiger-vnc), and open it from command line pointing it to the localhost IP and port:vncviewer 127.0.0.1:5900.
On the remote server
- Run whichever app you are trying to run in the Xvfb server:
DISPLAY=:99 google-chrome. It should show up in the VNC viewer.