As far as I can tell GDM3 is incompatible with RealVNC so I uninstalled it and I installed LightDM. However now I can't get anywhere when I try to connect to RealVNC.

What I did before was run:

sudo -u localuser vncserver-virtual

... and it opened up a VNC server on port 5901 to which I could connect. I still can, but now it displays the message:

Xsession: unable to start X session --- no .xsession file, no .Xsession file, no session managers, no window managers, and no terminal emulators found; aborting.

I'm guessing I need to make changes to my /etc/vnc/xstartup.custom file to somehow get X to detect LightDM? Its current contents seems centered around GDM:


[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey

if [ -f /usr/bin/gnome-session ]; then
  # Some gnome session types won't work with Xvnc, try to pick a sensible
  # default.
  for SESSION in "ubuntu-2d" "2d-gnome" "gnome-classic" "gnome-fallback"; do
    if [ -f /usr/share/gnome-session/sessions/$SESSION.session ]; then
      STARTUP="/usr/bin/gnome-session --session=$SESSION"; export STARTUP

XTERM_COMMAND="xterm -geometry 80x24+10+10 -ls"

if   [ -x /etc/X11/Xsession ]; then SESSIONBIN="/etc/X11/Xsession"
elif [ -x /etc/X11/xdm/Xsession ]; then SESSIONBIN="/etc/X11/xdm/Xsession"
elif [ -x /etc/X11/xinit/Xsession ]; then SESSIONBIN="/etc/X11/xinit/Xsession"
elif [ -x /etc/X11/gdm/Xsession ]; then SESSIONBIN="/etc/X11/gdm/Xsession gnome-session"
elif [ -x /etc/gdm/Xsession ]; then SESSIONBIN="/etc/gdm/Xsession gnome-session"
elif [ -x /etc/kde/kdm/Xsession ]; then SESSIONBIN="/etc/kde/kdm/Xsession"
elif [ -x /usr/dt/bin/Xsession ]; then
elif [ -x /usr/dt/bin/dtsession ]; then SESSIONBIN="/usr/dt/bin/dtsession"
elif which twm > /dev/null 2>&1; then

if [ "x${SESSIONBIN}" = "x" ]; then
  echo "No session located; just starting a terminal"
  echo "Terminal closed with return code $?"
  echo "Starting session: $SESSIONBIN"
  echo "Session terminated with return code $?"

vncserver-virtual -kill $DISPLAY

Any ideas what I need to change to get my RealVNC session to connect to LightDM?


It turns out the problem was that I hadn't installed a desktop environment, and I was running vncserver-??? in user mode. VNC server was trying to login as the user running it, rather than going to the login screen, and obviously failing as there was no desktop environment!

So either you have to install a desktop environment, or run VNC server in service mode to get the login screen.


By default the Desktop Managers are configured not to accept connections on the network. gdm seems to have have the capability removed, so I used xdm for VNC connections. If LightDM still has the capability to accept connections you will need to enable it.

The directories will be different, but the steps I use for xdm are:

  • Edit /etc/X11/xdm/xdm-config to comment out the DisplayManager.requestPort line. By default xdm is configured not to listen on for IP connections.
  • Edit /etc/X11/xdm/Xaccess to uncomment the line allowing any host to get a login window. Alteratively, you can just add a line reading localhost.
  • You may want to edit /etc/X11/xdm/Xsetup to uncomment the xsetroot line. xsetroot can also be used to provide a background picture or other effects.

These steps are extracted from my blog post on Remote Desktops with VNC and RDP.

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.