46

Greeting. I am on ubuntu 16.04 LTS. It is an amazon EC2 instance I got grey screen upon installing and starting the vncserver I try many suggestion regarding this issue but still cant get it work.... Thanks for the help

enter image description here

My logfile:

Xvnc Free Edition 4.1.1 - built Feb 25 2015 23:02:21
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.
Underlying X server release 40300000, The XFree86 Project, Inc
Tue Jul 19 03:03:37 2016
 vncext:      VNC extension running!
 vncext:      Listening for VNC connections on port 5901
 vncext:      created VNC server for screen 0
error opening security policy file /etc/X11/xserver/SecurityPolicy
Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/75dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/100dpi/, removing from list!
Tue Jul 19 03:03:44 2016
 Connections: accepted: 0.0.0.0::61550
 SConnection: Client needs protocol version 3.8
 SConnection: Client requests security type VncAuth(2)
Tue Jul 19 03:03:50 2016
 VNCSConnST:  Server default pixel format depth 16 (16bpp) little-endian rgb565
Tue Jul 19 03:03:51 2016
 VNCSConnST:  Client pixel format depth 8 (8bpp) colour-map

my 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" &
gnome-session &

15 Answers 15

36

I had the same issue on Ubuntu 16.04 LTS (64bit). I updated ~/.vnc/xstartup file to look like below, worked successfully for me.

# 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 &

gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &

Reference: https://www.linode.com/docs/applications/remote-desktop/install-vnc-on-ubuntu-16-04

3
  • 6
    This was a partial fix for me. Nautilus loads just fine but that is all I have. I do not see the icons along the left and I do not see any way to launch any programs, not even a terminal. If this helps at all, when I issue 'echo $DESKTOP_SESSION' it returns an empty string. Apr 26, 2018 at 19:54
  • 2
    I had to install gnome-panel via sudo apt install gnome-panel, but once I did that it worked.
    – pheeper
    Aug 15, 2018 at 15:38
  • Worked for me as charm. Ubuntu 19 client, Server Ubuntu 16.04.6 LTS
    – Vadim
    Dec 7, 2019 at 14:47
28

I had the same issue. To resolve it, I installed:

$ sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal

Then I added the lines below to ~/.vnc/xstartup:

gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
2
  • 2
    and then don't forget to kill and restart the vncserver (like I did)
    – craq
    Sep 3, 2018 at 4:56
  • Worked like a charm for me. Thanks a lot Jan 31, 2020 at 2:32
9

Not mentioned in any of the answers at the time of writing: it is also worth noting that the xstartup file needs to be executable:

chmod +x ~/.vnc/xstartup

If not, the grey screen issue continues to occur regardless of the contents of the file.

4

For anyone experiencing this problem on Xubuntu 16.04 LTS, I got my tightvncserver working by editing ~/.vnc/xstartup to this:

#!/bin/sh

xrdb $HOME/.Xresources
xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make GNOME work
#export XKL_XMODMAP_DISABLE=1
#/etc/X11/Xsession
# fix to make xfce work:
startxfce4 &

The first two commented-out lines were already commented out presumably by the packager. I commented out the two lines following "fix to make GNOME work", and added the last two lines, so it can be shortened to just

#!/bin/sh

xrdb $HOME/.Xresources
xsetroot -solid grey
# fix to make xfce work:
startxfce4 &

Again, this applies specifically to Xubuntu, not Ubuntu with Unity or Gnome.

1
  • Worked with Ubuntu 20.04 as well. Thanks. Jun 22, 2021 at 13:41
2

Just had the a similar problem and found a solution which I have not seen in any articles I read over the past few days trying to sort this out.

In addition to @Waqas answer I had to make sure I own all files in my home folder. Clearly this is about some specific files but I did'nt have time to check this out

sudo chown user:user /home/user

Just thought it might help somebody.

1

My xstartup config file already had following lines which were commented out by default.

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

un-commenting them fixed the problem and now i can access my desktop via vnc client smoothly. it still launches terminal window at logon but if you exit that then it shows the usual desktop via vnc.

0

All answers are partial. Hence, I'm writing this answer to help someone.

Step 1: Install Gnome Panel

$ sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal

Step 2: The xstartup file needs to be executable

chmod +x ~/.vnc/xstartup

Step 3: Update the ~/.vnc/xstartup file

Take your favorite editor and edit this file. Mine is vim. So I run the following command. vim ~/.vnc/xstartup.

Add the following lines to the file.

gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &

Step 4: Restart VNC Server

Kill the vncserver.

vncserver -kill :1

Start the vncserver.

vncserver :1

Step 5: Check whether it is working

Run nc IP PORT.

Example: nc 104.197.91.140 5901

1
  • This doesn't work for me followed the steps as mentioned.
    – krishna
    Aug 26, 2020 at 11:26
0

Sometimes, it is not brought by the xstartup file. The default one might be ok. Just try to use another port number (:2, :3, etc.). Works for me:)

0

I have Ubuntu 20 and I still have this issue.

I think the issue is that it is missing a desktop panel. Also, the line:

x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &

isn't helping at all as the -ls option will throw an error.

just having a line of x-terminal-emulator & or gnome-terminal & will pop up a terminal. At least it is better than a grey screen.

0

I'm sure there are many reasons for the "grey screen", but I hope this helps someone - I've just spent an afternoon battling with it only to find the the solution in MY case was:

Don't try to connect as the same user that's running a desktop session on the local machine.

As soon as I created a second user on the desktop, set up vnc for that user it worked immediately.

For the new user I

  • ran vncserver to create a password file
  • added xstartup (as per other posts in this thread)
  • touch .Xresources in the home directory
  • modified /etc/tigervnc/vncserver.users to point my session at the new user

And that sorted it. Good luck!

-1

I had the same issue after upgrading from 12.04 via 14.04 to 16.04. The essential tip that helped me was to install gnome-panel. Ref: http://www.linuxforums.org/forum/ubuntu-linux/209177-vnc-grey-screen-hi-res.html

sudo apt-get install gnome-panel
-1

I had the same issue, but found ~/.vnc/xstartup.bak to have my old config. I just needed to:

cp ~/.vnc/xstartup.bak ~/.vnc/xstartup
3
  • 1
    why do you assume everyone has a ".bak" file ready to use in this situation? and why should it help?
    – redbeam_
    Jan 3, 2020 at 1:36
  • @redbeam_ in my case my config had been destroyed by an upgrade. Hopefully this will help anyone else in the same situation where after an hour of trying different things I was able to solve it by restoring my previous config. Jan 23, 2020 at 21:11
  • well, I'm sure the average askubuntu user at least tries to look for backup files (in literally the same directory)
    – redbeam_
    Jan 24, 2020 at 22:16
-1

A general solution is to configure your Autostart settings to include xterm.

In KDE I used "System Settings" → "Startup and Shutdown" → Autostart

From there I click in "Add Program..." and write down xterm to it to the list of autostart programs.

Now the Xterm terminal, would appears in top of the gray background when using VNC. From there you can debug the commands in the .vnc/xstartup script, like startxfce4, or you can try manually the ones required for minimal desktop functionality:

xfwm4 & #window manager
xfce4-panel  &
xfdesktop & 
-1

This is a error caused by the config file which was badly generated on VNC server install.

You just need and only need to update your file with the default one.

vncserver kill :1 
nano ~/.vnc/xstartup

Copy and paste the entire content to your ~/.vnc/xstartup

# 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 &

gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &

Save your file:

CTRL + X
Press (Y)es and (Y)es

Start your VNC server

vncserver

Log in with your VNC client.

-2

I finally got this working from vnc4server by "apt-get install xfce4", and found a working xtartup here (the rest of the tutorial was irrelevant for my needs, e.g. "apt-get install xfce4-*" was unneccessary): http://www.itzgeek.com/how-tos/linux/ubuntu-how-tos/how-to-install-vnc-on-ubuntu-16-04.html

#!/bin/sh
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
startxfce4 &

I've more or less concluded getting gnome to work in vnc is a non-starter.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .