Getting DietPi on RPi 4 to run headless (NOT headless install)

Hello, I just received my Raspberry Pi 4 today and immediately proceeded to install DietPi. I’m intending to use this as a headless Plex server, using VNC to access the desktop environment on another local computer. The initial setup was done with a keyboard/mouse combo and a monitor hooked up to the Pi, and during the initial setup I installed LXDE, RealVNC Server and Plex Server, which all worked fine, and I had DietPi login automatically and boot directly into LXDE, which also worked fine with the monitor (but no keyboard or mouse) hooked up. However, when I shut down, disconnected the HDMI cable, and replugged the power, it seems that the machine doesn’t boot into LXDE: the machine appears on my network, but VNC shows a black screen with “Cannot currently show the desktop”. Setting AUTO_SETUP_HEADLESS=1 in dietpi.txt doesn’t work either. Previously I had a Pi 2 Model B running Raspbian, and I could get it to boot headless into the desktop simply by not connecting the HDMI cable after initial setup and enabling VNC. Is there a way to force DietPi to load the desktop environment without a connected display?

ok first question: why do you install a desktop if you will run your system on headless mode?
second question: what VNC solution you use?
third question: how do you connect to your VNC

If you have a RPi you can install and operate RealVNC completely headless without any desktop solution installed.

Question 3: I’m running DietPC on an RPI 4 (see post subject line).
Question 2: As stated in my post, I installed RealVNC during initial setup, and am using the RealVNC Viewer on my other local computer.
Question 1: I know I can use SSH, but I wish to have a desktop environment because I have other family members who want to remotely access the Pi, and it’s too much of a chore to teach my 70+ year old mom and dad to use the command line.

ok let’s ask the other way around. Do you need the desktop directly on your RPi just for the Initial setup or do you need it later on as well?

Because you can simply install RealVNC from DietPi software catalog. no need for any other desktop software. This all can be setup completely headless.

Still my question, how do you connect. Do you use just the IP on the RealVNC client or do you add a :1 at the end?

https://dietpi.com/forum/t/resolved-removing-diversion-of-boot-overlays-readme-err/74/1

Yes, I will need a desktop environment, as I intend to use the machine for slideshow presentations in the future (I have uses that will need me to use an full Pi, rather than simply storing the presentations on a flash drive).

In terms of connecting via VNC, I’ve tried adding a :1 to the end of the IP address, but VNC Viewer simply says “The connection was refused by the computer”. Using just the IP address, VNC viewer asks for my username and password, but even after I correctly enter my username and password, the viewer simply shows a black screen with “Cannot currently show the desktop.”

ok, can you change to autologin feature and switch it back to default. means no automatic start of the desktop. than try to reboot your system. once done. login using SSH and check the status of the RealVNC service

1 Like

Soo I checked it myself on a RPi3B+. I installed LXDE + RealVNC and I’m able to login using VNC even without any screen attached. It doesn’t matter if I use 16 : LightDM login mask or 2 : Automatic login (root). It’s working ootb just using the IP address within RealVNC client. If I choose 0 : Manual login (default), than I need to add :1 to my IP address on the RealVNC client.

It should work when you disable shared VNC desktop in dietpi.txt. It will then spawn a virtual desktop on VNC connection. This is what Joulinar does work RealVNC when using screen :1 and this works with TigerVNC as well.

A shared desktop means that a real desktop session must already be active at the host, which is an overhead if you don’t use it. But also that should be possible without HDMI cable corrected :thinking:.

Sorry for the delay, I only just had the time to try again. It turns out I should have read the description on the DietPi software page ((resolved) Cannot log in to the MySQL server):

VNC servers start automatically during boot, unless you have selected Desktop as a dietpi-autostart option.

I’ve now selected auto-login only, and headless VNC to desktop works now. Sorry about that, I simply didn’t realize there was a page detailing all the optimized software packages. Thanks for all the help!

Ah I was not 100% aware of that as well. I think you can even have both, boot/autostart into local desktop session + virtual VNC session, but you need to change dietpi.txt entry SOFTWARE_VNCSERVER_DISPLAY_INDEX=1 to be e.g. 2, as index 1 is blocked by the local desktop, so VNC would then fail. … further checking code, ah nope, local desktop seems to be index 0… Then probably a local desktop session block Xserver capacities and hence only shared VPN session is possible. Need to do some testing, so we can maybe give some hint when installing VNC server while desktop autostart is active vice versa.

Hi, if you have autostart into local desktop session + virtual VNC, you can use index 0 as this will display the live desktop.

But this requires shared desktop mode the be active, doesn’t it? There is connects to index 0 automatically, but with TigerVNC it starts a different daemon then. On RealVNC however shared desktop daemon is running by default, hence when using index 0 on the VNC client it should indeed automatically show the local desktop.