I'm having some strange issues with a fresh VNC server install. I recently built a new Plex server, and it's running gnome Ubuntu 16.04. So far, I've gotten the openSSH server up and running with Google 2FA authentication. Now I'm working on getting vnc working so that I can ultimately run this headless, and remote into it with vnc through SSH when need be.

I started out running just:

sudo apt-get install vnc4server

then, ran vncserver to configure it and set the password, so far, so good.

I then went to my client PC (Windows 10), and attempted to connect without SSH, just to make sure it's working. That's the first issue, upon connecting, I'm getting just a grey screen, which I think is due to the desktop environment not coming up correctly with the connection is made, which I think I can fix by modifying the ~/.vnc/xstartup file.

So back on the server, I ran:

sudo gedit ~/.vnc/xstartup

Now I'm receiving an error, anytime I try to open a gui application as sudo, that error is:

[sudo] password for username:
No protocol specified
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused

(gedit:12145): Gtk-WARNING **: cannot open display: :0

Now I'm lost. I'm 100% sure this is related to VNC, but even shutting down the VNC server doesn't fix it.

Anyone got any ideas? I'm just spinning my wheels and getting frustrated at this point.


Recently I have been struggling with VNC on a Raspberry Pi. I got similar errors like you at the client side. I decided to install TightVNCserver instead of the default, since TightVNC got many good reviews. You can install TightVNC on your server (sudo apt-get install tightvncserver). First stop the other VNC server software or remove it. Then to test TightVNC, you log in as normal user, and set a VNC password.

$ tightvncpasswd

After that start tightvnc as normal user on your server.

$ tightvncserver

That would start VNC on your server.

Then on your local machine do the following, to build an ssh tunnel :

$ ssh -v remote-username@remote-hostname -L 5901:localhost:5901

This needed because VNC runs at localhost by default, but also needed to prevent plain text traffic.

After that start Remmina client, and configure it to connect to localhost:5901 with the remote username and the VNC password you created.

When this test works fine, you can continue to create a start-up script for boot time on your server, or decide to use it manually after each reboot.

Apart from VNC, the x2go is in my opinion nicer and easier to use. A very cool solution for a remote desktop. X2go is available in the Ubuntu repositories. For more info have a look here :


| improve this answer | |
  • Thanks for the suggestion, I tried removing vnc4server, and installing tightvnc, but I'm still getting the grey screen issue when attempting to connect, however a reboot did appear to fix the sudo issue I was having. – HandOfReform Jan 8 '17 at 6:03

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.