VNC Server: RFB 003.008

Thanks. Running firefox gave me Error: no DISPLAY environment variable specified
Following this link, I tried export DISPLAY=localhost:X with X=10.0 and 5901 and run firefox again. Both gave me Error: cannot open display: localhost:X

Let me note down what I did.

  1. Following this guide from @lesscomfortable, I installed ubuntu-desktop and vnc4server.
  2. ssh -L 5901:localhost:5901 paperspace@IP_ADRESS
  3. vncserver :1 -geometry 1200x900
  4. firefox then the above issues
  5. View VNC server (I use Mac’s Finder)
  6. Gray screen

During the dubgging, sometimes my vnc viewer show “Reconnecting…”, so I thin it is connected but just something is not working.

This is my vnc config - copied from the linked guide

paperspace@psldnr55y:~$ cat ~/.vnc/xstartup
#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &