User avatar
rin67630
Posts: 378
Joined: Fri Mar 04, 2016 10:15 am

SOLUTION: VNC does not start on a headless Raspberry pi.

Tue Jan 08, 2019 4:32 pm

I have massive problems to start a headless Raspberry Pi 3a (or a Zero W) running 2018-11-13-raspbian-stretch with VNC enabled.
The strnage thing is that being completely headless (without any Mouse/Keyboard) the system boots onto the desktop, stays many minutes (frequently forever) without loading VNC so one cannot connect.

I have anlysed /var/log/messages and found out these differences:
a) Without mouse and without keyboard:

Code: Select all

Jan  8 15:17:11 Stretch11 kernel: [   13.739217] Bluetooth: Core ver 2.22
Jan  8 15:17:11 Stretch11 kernel: [   13.739280] NET: Registered protocol family 31
Jan  8 15:17:11 Stretch11 kernel: [   13.739283] Bluetooth: HCI device and connection manager initialized
Jan  8 15:17:11 Stretch11 kernel: [   13.739302] Bluetooth: HCI socket layer initialized
Jan  8 15:17:11 Stretch11 kernel: [   13.739312] Bluetooth: L2CAP socket layer initialized
Jan  8 15:17:11 Stretch11 kernel: [   13.739358] Bluetooth: SCO socket layer initialized
Jan  8 15:17:11 Stretch11 kernel: [   13.798870] Bluetooth: HCI UART driver ver 2.3
Jan  8 15:17:11 Stretch11 kernel: [   13.798879] Bluetooth: HCI UART protocol H4 registered
Jan  8 15:17:11 Stretch11 kernel: [   13.798882] Bluetooth: HCI UART protocol Three-wire (H5) registered
Jan  8 15:17:11 Stretch11 kernel: [   13.799025] Bluetooth: HCI UART protocol Broadcom registered
Jan  8 15:17:12 Stretch11 kernel: [   14.333428] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
Jan  8 15:17:12 Stretch11 kernel: [   14.333441] Bluetooth: BNEP filters: protocol multicast
Jan  8 15:17:12 Stretch11 kernel: [   14.333461] Bluetooth: BNEP socket layer initialized
Jan  8 15:17:12 Stretch11 kernel: [   14.397122] Bluetooth: RFCOMM TTY layer initialized
Jan  8 15:17:12 Stretch11 kernel: [   14.397154] Bluetooth: RFCOMM socket layer initialized
Jan  8 15:17:12 Stretch11 kernel: [   14.397178] Bluetooth: RFCOMM ver 1.11
Jan  8 15:17:14 Stretch11 kernel: [   16.795565] fuse init (API version 7.26)
[b]Jan  8 16:12:50 Stretch11 kernel: [  316.155022] random: crng init done
Jan  8 16:12:50 Stretch11 kernel: [  316.155036] random: 7 urandom warning(s) missed due to ratelimiting[/b]
Jan  8 16:12:50 Stretch11 vncserver-x11[418]: ServerManager: Server started
Jan  8 16:12:50 Stretch11 vncserver-x11[418]: ConsoleDisplay: Found running X server (pid=458, binary=/usr/lib/xorg/Xorg)
Jan  8 16:12:51 Stretch11 vncserver-x11[418]: Connections: connected: 192.168.188.21::60722
Jan  8 16:12:52 Stretch11 vncserver-x11[418]: Connections: authenticated: 192.168.188.21::60722, as pi (f permissions)

With a mouse plugged in:

Code: Select all

Jan  8 16:31:32 Stretch11 kernel: [   12.456853] Bluetooth: Core ver 2.22
Jan  8 16:31:32 Stretch11 kernel: [   12.456928] NET: Registered protocol family 31
Jan  8 16:31:32 Stretch11 kernel: [   12.456935] Bluetooth: HCI device and connection manager initialized
Jan  8 16:31:32 Stretch11 kernel: [   12.456955] Bluetooth: HCI socket layer initialized
Jan  8 16:31:32 Stretch11 kernel: [   12.456968] Bluetooth: L2CAP socket layer initialized
Jan  8 16:31:32 Stretch11 kernel: [   12.457001] Bluetooth: SCO socket layer initialized
Jan  8 16:31:32 Stretch11 kernel: [   12.490987] Bluetooth: HCI UART driver ver 2.3
Jan  8 16:31:32 Stretch11 kernel: [   12.491000] Bluetooth: HCI UART protocol H4 registered
Jan  8 16:31:32 Stretch11 kernel: [   12.491006] Bluetooth: HCI UART protocol Three-wire (H5) registered
Jan  8 16:31:32 Stretch11 kernel: [   12.491214] Bluetooth: HCI UART protocol Broadcom registered
Jan  8 16:31:32 Stretch11 kernel: [   12.796262] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
Jan  8 16:31:32 Stretch11 kernel: [   12.796270] Bluetooth: BNEP filters: protocol multicast
Jan  8 16:31:32 Stretch11 kernel: [   12.796284] Bluetooth: BNEP socket layer initialized
Jan  8 16:31:32 Stretch11 kernel: [   12.847773] Bluetooth: RFCOMM TTY layer initialized
Jan  8 16:31:32 Stretch11 kernel: [   12.847812] Bluetooth: RFCOMM socket layer initialized
Jan  8 16:31:32 Stretch11 kernel: [   12.847833] Bluetooth: RFCOMM ver 1.11
Jan  8 16:31:32 Stretch11 lightdm[514]: Error getting user list from org.freedesktop.Accounts: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Accounts was not provided by any .service files
Jan  8 16:31:36 Stretch11 kernel: [   16.405159] fuse init (API version 7.26)
Jan  8 16:31:38 Stretch11 vncserver-x11[413]: Connections: connected: 192.168.188.21::60863
Jan  8 16:31:38 Stretch11 vncserver-x11[413]: Connections: authenticated: 192.168.188.21::60863, as pi (f permissions)
Jan  8 16:34:20 Stretch11 kernel: [  172.624444] Voltage normalised (0x00000000)
Jan  8 16:34:28 Stretch11 vncserver-x11[413]: Connections: disconnected: 192.168.188.21::60863 ([ViewerClosed] VNC Viewer geschlossen)
Jan  8 16:35:23 Stretch11 vncserver-x11[413]: Connections: connected: 192.168.188.21::60897
Jan  8 16:35:23 Stretch11 vncserver-x11[413]: Connections: authenticated: 192.168.188.21::60897, as pi (f permissions)
So it seems that "random: crng init done" blocks.
I have read that: "At boot, the kernel waits for mouse movements to initialize the random number generator."

The SOLUTION: install haveged (an entropy generator that does not need a mouse)
sudo apt-get install haveged.

User avatar
sconemad
Posts: 228
Joined: Thu Apr 28, 2016 1:47 pm
Location: Cambridge, UK
Contact: Website

Re: SOLUTION: VNC does not start on a headless Raspberry pi.

Sat Jan 12, 2019 5:52 pm

That's very helpful. Thanks for posting this!

GavinD
Posts: 8
Joined: Mon May 09, 2016 9:20 pm
Contact: Website

Re: SOLUTION: VNC does not start on a headless Raspberry pi.

Fri Feb 15, 2019 10:37 am

Thankyou - that cured it for me too.

HaCo
Posts: 1
Joined: Tue Mar 05, 2019 7:48 pm

Re: SOLUTION: VNC does not start on a headless Raspberry pi.

Tue Mar 05, 2019 8:04 pm

Thanks a lot, had the same problem on my new Zero W!

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

Re: SOLUTION: VNC does not start on a headless Raspberry pi.

Tue Mar 05, 2019 9:19 pm

It seems strange that this problem has been reported many times over past few months but that no fix or acknowledgement seems to have been offered by RPi (that I've seen)

TheBoatbuilder
Posts: 1
Joined: Sun Mar 17, 2019 8:37 am

Re: SOLUTION: VNC does not start on a headless Raspberry pi.

Sun Mar 17, 2019 12:12 pm

I have had the same issue with my Pi 3A+.
My Pi 3B+ using Linux 4.14.79 runs VNC from Boot without issue but my Pi 3A+ on Linux 4.14.98 failed.

I did a fresh install of Raspbian and tried all the obvious things to diagnose the issue. Two hours later I called it quits to get some sleep.
Then I found this post and spotted the key to firing up VNC post Boot; mouse movement.
Having installed haveged by following these instructions https://www.techrepublic.com/article/ho ... -on-linux/

Open a terminal window
Issue the command sudo apt-get install haveged
Allow the installation to complete
Set haveged up to start at boot with the command sudo update-rc.d haveged defaults

All is OK.

Many thanks but would it be possible to have an OS fix to save others from this nightmare.

Mark

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

Re: SOLUTION: VNC does not start on a headless Raspberry pi.

Tue Mar 19, 2019 4:34 pm

Many thanks for this - I've just been redirected here from my own thread.
Works for me...

cinti
Posts: 3
Joined: Wed Dec 16, 2015 2:44 pm

Re: SOLUTION: VNC does not start on a headless Raspberry pi.

Tue Mar 26, 2019 8:16 pm

Great, thank you! Given the number of folks running their Pi headless, shouldn't the Pi org make this install standard on the distro?

Ihf
Posts: 3
Joined: Sun Feb 04, 2018 2:46 am

Re: SOLUTION: VNC does not start on a headless Raspberry pi.

Sat Jun 29, 2019 2:11 am

I just had the same problem with a headless Pi Zero W and figured out that mouse movement was the fix (which is obviously not what you want for a headless system). I installed haveged and the problem seems to be resolved. Apparently it is waiting for enough activity to fill a cache. Thank you to those who found it.

electronicman
Posts: 30
Joined: Mon Dec 10, 2012 9:31 pm
Location: USA

Re: SOLUTION: VNC does not start on a headless Raspberry pi.

Mon Aug 12, 2019 7:57 pm

I have been having the same issues with any of my Pi's.
Found out that if you SSH in to it, it does not always connect first time, but when SSH connects then you can use VNC without a problem.
David

echmain
Posts: 224
Joined: Fri Mar 04, 2016 8:26 pm

Re: SOLUTION: VNC does not start on a headless Raspberry pi.

Tue Aug 13, 2019 12:30 am

My solution to this was to use an HDMI “dummy plug”.

It’s a small dongle plugged into the HDMI port that makes the OS think there’s a monitor plugged in.

It was $6 and required no additional installs, drivers or anything else.

VNC now works perfectly. I access it from my iPad.

Return to “Troubleshooting”