hwdornbush
Posts: 19
Joined: Fri Jan 20, 2017 7:08 pm

VNC Interface won't stay enabled

Fri Jul 27, 2018 12:05 am

I have a Raspberry Pi Zero W that I just loaded with the latest Stretch image. To start using it, I plugged in a monitor, keyboard, and mouse and set it up for use. As part of that, I enabled the SSH and VNC interfaces. That all seemed fine. But several times, unfortunately not every time, when I shutdown the Pi and then power cycle to restart it, the VNC Interface is disabled. The SSH interface stays enabled and I can use it to re-enable VNC using "sudo raspi-config" and then enabling the VNC interface.

I have not seen this problem on any of my other Raspberry Pi's which are all Raspi 3 Model B.

What can I do to keep the VNC interface enabled?

hwdornbush
Posts: 19
Joined: Fri Jan 20, 2017 7:08 pm

Re: VNC Interface won't stay enabled

Thu Aug 09, 2018 4:32 pm

After some more time working with this issue, I find that VNC is erratically enabled. That is, when I reboot a ZeroW that I just ran VNC on, it *may* start and refuse VNC connection, but if I reboot it, it again *may* refuse VNC connection, but eventually (usually after one reboot) it will allow VNC again. My VNC client is Windows 10. Is this unique to me? Is no one else seeing this?

mattmiller
Posts: 2061
Joined: Thu Feb 05, 2015 11:25 pm

Re: VNC Interface won't stay enabled

Thu Aug 09, 2018 4:55 pm

Not heard of that one before.


Given the fact that you have a load of other Pi that work fine, I'd try out an SD card from one of them in it and see what happens

(And try the PiZeroW SD card out in one of the Pi3 also)

peliopoulos
Posts: 2
Joined: Fri Mar 29, 2019 12:15 am

Re: VNC Interface won't stay enabled

Fri Mar 29, 2019 12:17 am

I am running into the same situation with Raspbian installed from the latest PINN on a Zero W. I use RealVNC all the time, but I keep having to ssh in and run the raspi-config command to enable VNC. I wish I knew where the enablement was stored so I could edit that file.

Andyroo
Posts: 3311
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: VNC Interface won't stay enabled

Fri Mar 29, 2019 12:44 am

Do you have a keyboard or mouse plugged into the remote PI?

If not try:

Code: Select all

sudo apt-get install haveged
sudo update-rc.d haveged defaults
Then do a reboot. These two commands install a generator of entropy (how the Pi creates randomness) that adds to the amount created by mouse / keyboard movements - see here for a bit more info.

Somewhere in VNC it must use this (possibly for session encryption) and hangs till a random value (or values) is returned hence sometimes it starts and sometimes it does not. Sorry my math is not good enough to follow some of the processes involved :lol:
Need Pi spray - these things are breeding in my house...

MarkDH102
Posts: 326
Joined: Fri Feb 13, 2015 3:18 pm

Re: VNC Interface won't stay enabled

Fri Mar 29, 2019 7:11 am

This really needs sorting or a sticky being put up somewhere. It seems to be catching a lot of people out.
Is it a bug in the kernel? Why after many years of VNC working fine has it suddenly started happening?

User avatar
HawaiianPi
Posts: 4229
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: VNC Interface won't stay enabled

Fri Mar 29, 2019 7:52 am

MarkDH102 wrote:
Fri Mar 29, 2019 7:11 am
This really needs sorting or a sticky being put up somewhere. It seems to be catching a lot of people out.
Is it a bug in the kernel? Why after many years of VNC working fine has it suddenly started happening?
I've never had that problem, and most of my Pi computers run headless. We even VNC into a Pi in another state sometimes.

Is everyone having this trouble using the official RealVNC Viewer, or something else (like TightVNC)?
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

MarkDH102
Posts: 326
Joined: Fri Feb 13, 2015 3:18 pm

Re: VNC Interface won't stay enabled

Fri Mar 29, 2019 8:07 am

No, I'm using the standard REALVNC.
3 * Pi0w are all exhibiting the same problem.
All my pi's - Stretch - are updated once a month.
I can't say when the problem started, as I had a power cut, all my pi's rebooted. Then found I couldn't connect.
I only have a screen plugged into one of them and after tearing my hair out over not being able to connect, I noticed the REALVNC icon was not on the menu bar but after 10m or so, it magically appeared and I was able to connect as normal.
With the fix mentioned, all is well.

mattmiller
Posts: 2061
Joined: Thu Feb 05, 2015 11:25 pm

Re: VNC Interface won't stay enabled

Fri Mar 29, 2019 9:09 am

For some strange reason, no-one at RPi seems to have noticed that this issue keeps on being raised

User avatar
B.Goode
Posts: 7868
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: VNC Interface won't stay enabled

Fri Mar 29, 2019 10:15 am

peliopoulos wrote:
Fri Mar 29, 2019 12:17 am
I am running into the same situation with Raspbian installed from the latest PINN on a Zero W. I use RealVNC all the time, but I keep having to ssh in and run the raspi-config command to enable VNC. I wish I knew where the enablement was stored so I could edit that file.

Welcome to the Raspberry Pi forums.


The raspi-config utility is a shell script stored at /usr/bin/raspi-config

It is a clear text file that can be read or inspected with any file viewer or text editor. Minimally, cat or less could be used.


The relevant content appears to be the following:

Code: Select all

get_vnc() {
  if systemctl status vncserver-x11-serviced.service  | grep -q inactive; then
    echo 1
  else
    echo 0
  fi
}

do_vnc() {
  DEFAULT=--defaultno
  if [ $(get_vnc) -eq 0 ]; then
    DEFAULT=
  fi
  if [ "$INTERACTIVE" = True ]; then
    whiptail --yesno "Would you like the VNC Server to be enabled?" $DEFAULT 20 60 2
    RET=$?
  else
    RET=$1
  fi
  if [ $RET -eq 0 ]; then
    if [ ! -d /usr/share/doc/realvnc-vnc-server ] ; then
        apt-get install realvnc-vnc-server
    fi
    systemctl enable vncserver-x11-serviced.service &&
    systemctl start vncserver-x11-serviced.service &&
    STATUS=enabled
  elif [ $RET -eq 1 ]; then
    systemctl disable vncserver-x11-serviced.service &&
    systemctl stop vncserver-x11-serviced.service &&
    STATUS=disabled
  else
    return $RET
  fi
  if [ "$INTERACTIVE" = True ]; then
    whiptail --msgbox "The VNC Server is $STATUS" 20 60 1
  fi
}

However, that script seems to indicate that the relevant service should be enabled and started, and that is a status that should persist over a reboot. It seems there is some other issue at play for the OP?

The entropy problem is one possible cause. Another might be that this could be a symptom of a microSD card that has spontaneously entered a read-only state?

Andyroo
Posts: 3311
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: VNC Interface won't stay enabled

Sat Mar 30, 2019 8:40 pm

Apologies to all - my paste was only partial :oops:

Code: Select all

sudo apt-get install haveged
sudo systemctl enable haveged
sudo systemctl start haveged
are the THREE commands that need to be issued.
Need Pi spray - these things are breeding in my house...

peliopoulos
Posts: 2
Joined: Fri Mar 29, 2019 12:15 am

Re: VNC Interface won't stay enabled

Sat Mar 30, 2019 9:34 pm

Thanks B. Goode! Turns out that the I think I needed to be patient - I think I might have been too quick in trying to connect.

User avatar
HawaiianPi
Posts: 4229
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: VNC Interface won't stay enabled

Sat Mar 30, 2019 10:04 pm

mattmiller wrote:
Fri Mar 29, 2019 9:09 am
For some strange reason, no-one at RPi seems to have noticed that this issue keeps on being raised
I've been on this forum for quite awhile and I haven't seen it mentioned often. Unless you have evidence to the contrary, you seem to be blowing this way out of proportion.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

andrum99
Posts: 573
Joined: Fri Jul 20, 2012 2:41 pm

Re: VNC Interface won't stay enabled

Sat Mar 30, 2019 11:59 pm

Andyroo wrote:
Sat Mar 30, 2019 8:40 pm
Apologies to all - my paste was only partial :oops:

Code: Select all

sudo apt-get install haveged
sudo systemctl enable haveged
sudo systemctl start haveged
are the THREE commands that need to be issued.

An alternative is to install the rng-tools package, which hooks the Pi's built-in random number generator hardware up to the kernel as an entropy source. This has just been added to the tool that builds the official Raspbian images, so will appear in the next official release of Raspbian and Raspbian Lite. To install rng-tools and start it:

Code: Select all

sudo apt update
sudo apt install rng-tools
sudo systemctl start rng-tools
You don't need to explicitly enable rng-tools - it is enabled by default when it is installed.

klricks
Posts: 6436
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: VNC Interface won't stay enabled

Sun Mar 31, 2019 12:25 am

Andyroo wrote:
Sat Mar 30, 2019 8:40 pm
Apologies to all - my paste was only partial :oops:

Code: Select all

sudo apt-get install haveged
sudo systemctl enable haveged
sudo systemctl start haveged
are the THREE commands that need to be issued.
It is not necessary to do the 2nd and 3rd commands.
The install will auto configure and run the haveged process.

Code: Select all

sudo apt install haveged
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

hwdornbush
Posts: 19
Joined: Fri Jan 20, 2017 7:08 pm

Re: VNC Interface won't stay enabled

Mon Apr 01, 2019 10:57 pm

I am the OP. I had this problem with I was first setting up two Pi Zero W's to be used to send weather information to another Pi. I had the problem several times as I was developing these systems. However, once they were running regularly, as they have for many months now, the problem has not re-occurred. I don't believe it was a Micro SD card issue as they are still using the same cards. I just connected with both of them using VNS without any problem. Of course,they have not been rebooted much and the problem seemed to occur when they were rebooted.

Return to “Troubleshooting”