DietPi VNC Server Headless....head wrecked!

Hi Folks

Seen a couple of threads on this but none are getting me over the line.

Basically, I have a RPi4, with no keyboard/mouse/monitor (either during setup or continued use). I flash the SD card, drop the pre-edited dietpi.txt file on it and let it self install (for the most part)

I want to be able to connect to a desktop environment on the Rpi via VNC. Have no need for the desktop to actually run on the Pi, unless its required to do what I need.

I’ve tried connecting with both RoyalTSX and Real VNC Viewer. No dice. Ive tried every solution I have seen re autologin, desktop resolution, hdmi-safe, shared-desktop=0 or 1, connecting to 5901, connecting to IP only, connecting to IP with :1 at the end.

Real VNC viewer consistently gives me ‘Cannot currently show the desktop’ tho it is making a connection.

This is my initial dietpi.txt. Any one got suggestions?

Appreciate any insight.

# - This is intended for advanced users, unless you know what you are doing, do not edit this file. Please use the DietPi programs instead.
# - Modifications to /boot/dietpi.txt will not be preserved on reboot.
# - Please ensure you edit from the DietPi-RAMdisk location: /DietPi/dietpi.txt
# - Do not remove uncommented lines, as the items are scraped by DietPi programs, on demand.

# D I E T - P I
# DietPi-Automation settings, applied on first boot of DietPi only, ONCE!
##### Language/Regional Options #####
# Locale: eg: "en_GB.UTF-8" / "de_DE.UTF-8" | One entry and UTF-8 ONLY!

# Keyboard Layout eg: "gb" / "us" / "de" / "fr"

# Timezone eg: "Europe/London" / "America/New_York" | Full list (TZ*):

##### Networking Options #####
# Enable Ethernet or WiFi adapter: 1=enable | 0=disable
# - If both Ethernet and WiFi are enabled, WiFi will take priority and Ethernet will be disabled.
# - If using WiFi, please edit dietpi-wifi.txt to pre-enter credentials.

# Force ethernet speeds: 0=automatic speed | 10 = 10Mbit | 100 = 100Mbit etc
# - This is mainly aimed at Pine A64 which may have an HW issue that causes unstable 1Gbit link.

# Enter your Static Network details below, if applicable.

# Hostname

##### Misc Options #####
# Swapfile size to generate: 0=disable | 1=auto (2GB-RAM = size) | 2+=manual (MB)
# Swapfile location

# Disable HDMI output (and GPU/VPU where supported) for supported devices: RPi, Odroid C1, Odroid C2

# Unmask (enable) systemd-logind service, which is masked by default on DietPi

# Custom Script (pre-networking and pre-DietPi install)
# - Allows you to automatically execute a custom script before network is up on first boot.
# - Copy your script to /boot/ and it will be executed automatically.
# - Executed script log: /var/tmp/dietpi/logs/dietpi-automation_custom_prescript.log

# Custom Script (post-networking and post-DietPi install)
# - Allows you to automatically execute a custom script at the end of DietPi install.
# - Option 0 = Copy your script to /boot/ and it will be executed automatically.
# - Option 1 = Host your script online, then use e.g. AUTO_SETUP_CUSTOM_SCRIPT_EXEC= and it will be downloaded and executed automatically.
# - Executed script log: /var/tmp/dietpi/logs/dietpi-automation_custom_script.log

##### Software Options #####
# SSH Server Selection: 0=none/custom | -1=Dropbear | -2=OpenSSH

# File Server Selection: 0=none/custom | -1=ProFTP | -2=Samba

# Logging Mode Selection: 0=none/custom | -1=RAMlog 1h clear | -2=RAMlog 1h save clear | -3=rsyslog + logrotate
# RAMlog max tmpfs size (MB). 50MB should be fine for single use. 200MB+ for heavy webserver and access log etc.

# Webserver Preference Selection: 0=Apache2 | -1=Nginx | -2=Lighttpd
# - This will be ignored if you have manually selected any webserver stack.

# DietPi-Autostart: 0=Console | 7=Console autologin | 1=Kodi | 2=Desktop autologin | 16=Desktop | 3=RetroPie | 4=OpenTyrian | 5=DietPi-Cloudshell | 6=Amiberry fast boot | 8=Amiberry standard boot | 9=DDX-Rebirth | 10=CAVA Spectrum | 11=Chromium kiosk | 14=Custom autostart service
# - This will be effective on 2nd boot, after firstrun update and installs have been done.
# - Related software titles must be installed either on firstrun installs or via AUTO_SETUP_AUTOMATED=1 + AUTO_SETUP_INSTALL_SOFTWARE_ID (see below).
# Autologin user name
# - This user must exist before firstrun installs, otherwise it will be reverted to root.
# - Applies to all autostart options but: 0, 6, 14 and 16

##### Non-interactive Firstrun Setup #####
# On first login, run update, initial setup and software installs without any user input
# - Setting this to "1" is required for below settings to take effect
# - It is HIGHLY recommended to also set CONFIG_BOOT_WAIT_FOR_NETWORK=2, to force infinite wait for network connection during boot and prevent connection timeout errors.

# Global Password to be applied for the system
# - Affects user "root" and "dietpi" login passwords, and, all software installed by dietpi-software, that requires a login password
# - WARN: Passwords with any of the following characters are not supported: \"$

# Software to automatically install
# - List of available software IDs:
# - Add as many entries as you wish, one each line.
# - DietPi will automatically install all pre-reqs (e.g. ALSA/X11 for desktops etc)
# - E.g. the following (without the leading "#") will install the LXDE desktop automatically on first boot:







# D I E T - P I
# Misc DietPi program settings
# DietPi-Survey: 1=opt in | 0=opt out | -1=ask on first call
# -

# D I E T - P I
# DietPi-Config settings
# CPU Governor: powersave | conservative | ondemand | performance
# Ondemand Sampling Rate | Min value: 10000 microseconds (10ms)
# Ondemand Sampling Down Factor: Samling Rate * Down Factor / 1000 = ms (40 = 1000ms when sampling rate is 25000)
# Throttle Up Percentage: Percentage of average CPU usage during samling rate at which CPU will be throttled up/down

# CPU Frequency Limits: Disabled=disabled
# - Intel CPUs use a percentage value (%) from 0-100, eg: 55
# - All other devices must use a specific MHz value, eg: 1600
# - Has no effect on RPi, please set "arm_freq" and "arm_freq_min" in config.txt instead.

# Disable Intel-based turbo/boost stepping. This flag should not be required, setting <100% MAX frequency should disable Turbo on Intel CPUs.

# System-wide proxy settings
# - Do not modify, you must use dietpi-config > "Network Options: Adapters" to apply

# Delay boot until network is established: 0=disabled | 1=10 second wait max (default) | 2=infinite wait

# Connection timeout, before DietPi G_CHECK_URL assumes the URL is dead. Increase if you have a "flaky" connection or slow DNS resolver.
# - Set this to "0" to allow unlimited time, however this is not recommended to avoid unlimited hanging background scripts, e.g. daily DietPi update check.
# Connection attempts with above timeout each, before DietPi G_CHECK_URL is giving up and prompts an error.
# - Set this to "0" to disable URL checking completely, however this is not recommended to avoid harder to debug follow-up errors during APT and download attempts.
# General connection and DNS testing
# - IP to ping when checking network connectivity. Default: (Cloudflare DNS, should be very fast world-wide)
# - Domain to ping when checking DNS resolver. Default: (Cloudflare DNS domain, see above)

# DietPi checks for updates: Allows DietPi to check for updates on a daily basis and boot using a <1kb file download.
# Optional: Automatically update DietPi when updates are available. Requires: CONFIG_CHECK_DIETPI_UPDATES=1

# Network time sync: 0=disabled | 1=boot only | 2=boot + daily | 3=boot + hourly | 4=Daemon + Drift

# WiFi country code: 2 character value (eg GB US DE JP):

# Serial Console: Set to 0 if you do not require serial console.

# Soundcard

# LCD Panel addon
# - Do not modify, you must use dietpi-config to configure/set options

# IPv6

# Prefer IPv4 with APT and wget, NB: This has no effect if IPv6 is disabled anyway!

# APT mirrors which are applied to /etc/apt/sources.list | Values here will also be applied during 1st run setup
# - Raspbian:
# - Debian:

# NTP mirror, applied to /etc/ntp.conf
# - For a full list, please see:
# - Please remove the initial integer and full stop from the value (removing "0."), eg:

# D I E T - P I
# DietPi-Software settings
# Enter your write API key here. It will be applied automatically during EmonPi/Hub install.
# - Eg: SOFTWARE_EMONHUB_APIKEY=b4dfmk2o203mmxx93a

# VNC Server

# ownCloud/Nextcloud
# - Optional username for admin account, the default is 'admin', applied during install
# - Optional data directory, default is "/mnt/dietpi_userdata/owncloud_data" respectively "/mnt/dietpi_userdata/nextcloud_data", applied during install
#	NB: This option is for advanced users. For full compatibility, please keep this options defaults, and, use dietpi-drive_manager to move the DietPi user data location.

# WiFi Hotspot
# - Key requires a minimum of 8 characters

# - DPI 96(default) 120(+25%) 144(+50%) 168(+75%) 192(+100%)

# Chromium

# Home Assistant
# - Optional Python build dependencies and modules, possibly required for certain HA components
#	Space separated list (no quotation!), will be installed together with Home Assistant automatically, if present
#	Add Python modules with version string at best, e.g.: firstModule==1.2.3 secondModule==4.5.6

# D I E T - P I
# Dev settings

# D I E T - P I
# Settings, automatically added by dietpi-update


usually RealVNC is working quite nice on a RPi. You installed RealVNC from dietpi-software catalogue? What IP syntax you are using on your RealVNC client?

So I installed it both ways (via the dietpi.txt dropped onto the SD card before first boot) and also to via dietpi-software after initial boot/config. I also tried TigerVNC with no success

For IP connection I tried: (connects but gives ‘Cannot currently show the desktop’) (Connection refused by computer) refused by computer)

Details on initial settings used are all in the DietPi.txt in OP.

Appreciate you taking the time to respond!

Do you use any other desktop software or auto start feature? Usually IP:1 should be working.

I have literally nothing other than the items listed in the attached dietpi.txt installed or configured.

can you recheck VNC server settings?

cat /DietPi/dietpi.txt|grep SOFTWARE_VNCSERVER

Usually DISPLAY_INDEX should be set to 1. As well you could have a look to the port that is used ss -alnp | grep Xvnc-core

So I just flashed the card and did a fresh install, so literally no settings have been tweaked since the install from the first boot dietpi.txt installation quoted above

cat /DietPi/dietpi.txt|grep SOFTWARE_VNCSERVER returns


ss -alnp | grep Xvnc-core returns nothing

Connection to with no port/display as root/dietpi establishes connection but gives message ‘Cannot currently display the desktop’

well if ss -alnp | grep Xvnc-core doesn’t give anything back, could indicate the VNC Server is not running. Can you have a look the VNC services, if they are up and running?

Output of systemctl status vncserver.service

● vncserver.service - Manage VNC Server (DietPi)
   Loaded: loaded (/etc/systemd/system/vncserver.service; enabled; vendor preset: enabled)
   Active: active (exited) since Tue 2020-04-28 15:56:11 BST; 22min ago
  Process: 777 ExecStart=/usr/local/bin/vncserver start (code=exited, status=0/SUCCESS)
 Main PID: 777 (code=exited, status=0/SUCCESS)

Apr 28 15:56:11 raspberrypi-emby systemd[1]: Started Manage VNC Server (DietPi).
Apr 28 15:56:11 raspberrypi-emby systemd[777]: pam_unix(login:session): session opened for user root by (uid=0)

Wouldnt the attempted connection via VNC viewer fail if the service was stopped? Rather than establishing connection but not being able to show the desktop?

strange Xvnc-core would need to be active and it’s started by vncserver.service. for testing purposes, can you stop vncserver.service and try to start vnc server manual

root@DietPi3:~# systemctl stop vncserver.service
root@DietPi3:~# /usr/local/bin/vncserver start

Tried that and ss -alnp | grep Xvnc-core still returns nada

but what is the output of the manual start? for me the last lines looks like this

Running applications in /root/.vnc/xstartup

VNC Server catchphrase: "Spider state mercury. Carrot diet Henry."
             signature: 38-24-c0-46-a4-10-d0-34

Log file is /root/.vnc/DietPi3:1.log
New desktop is DietPi3:1 (

‘/usr/local/bin/vncserver start’ does not appear to restart the vnc server service at all. Running it does not error out but it returns no output

yes that’s correct. ths command did not restart the service. It will start the server manually only. Anyhow it should give anything back. For me it’s quite a long output. Still something seems to be strange on your VNC installation. can you do ps -ef|grep vnc and post the entire output

root@raspberrypi-emby:~# ps -ef|grep vnc
root       492     1  0 19:11 ?        00:00:00 /usr/bin/vncserver-x11-serviced -fg
root       494     1  0 19:11 ?        00:00:00 /usr/bin/vncserver-virtuald -fg
root       522   492  0 19:11 ?        00:00:00 /usr/bin/vncserver-x11-core -service
root      1029   949  0 19:12 pts/0    00:00:00 grep vnc

that’s all?? I have way more processes running

root@DietPi3:~# ps -ef|grep vnc
root       430     1  0 20:17 ?        00:00:00 /usr/bin/vncserver-x11-serviced -fg
root       433     1  0 20:17 ?        00:00:00 /usr/bin/vncserver-virtuald -fg
root       444   430  0 20:17 ?        00:00:00 /usr/bin/vncserver-x11-core -service
root       635     1  0 20:17 ?        00:00:00 /usr/bin/vncserver :1 -geometry 2160x1440 -depth 16
root       637   635  4 20:17 ?        00:00:00 /usr/bin/Xvnc-core :1 -auth /root/.Xauthority -pn -geometry 2160x1440 -depth 16
root       654   635  0 20:17 ?        00:00:00 /bin/sh /etc/vnc/xstartup
root       681     1  3 20:17 ?        00:00:00 /usr/bin/vncserverui virtual 13
root       695   681  1 20:17 ?        00:00:00 /usr/bin/vncserverui -statusicon 5
root       857   777  0 20:18 pts/0    00:00:00 grep vnc


Do you have a spare SD card and could do a fresh install? Something seems to be wrong

yup, thats all of it

This was a fresh install about 60 mins ago. Wiped the SD card, included the RealVNC installation in the dietpi.txt that was on the SD card before first boot. Literally nothing else done since.

The first install also includes
samba client

I might strip back the rest, and literally just do realVNC (and manually via dietpi-software) and see what happens, in case there is some weird issues during install.

Currently it looks like there is no xsession started for VNC

Ok. So a fresh install, cutting the dietpi.txt for first boot to the bare bones of just the IP address required, plus a manual install of realVPN via dietpi-software, got my ps -ef | grep vnc to display this

root@dietpi-server1:~# ps -ef | grep vnc
root       495     1  0 21:00 ?        00:00:00 /usr/bin/vncserver-virtuald -fg
root       504     1  0 21:00 ?        00:00:00 /usr/bin/vncserver-x11-serviced -fg
root       529   504  0 21:00 ?        00:00:00 /usr/bin/vncserver-x11-core -service
root       682     1  0 21:00 ?        00:00:00 /usr/bin/vncserver :1 -geometry 1280x720 -depth 16
root       684   682  0 21:00 ?        00:00:01 /usr/bin/Xvnc-core :1 -auth /root/.Xauthority -pn -geometry 1280x720 -depth 16
root       697   682  0 21:00 ?        00:00:00 /bin/sh /etc/vnc/xstartup
root       732     1  0 21:00 ?        00:00:00 /usr/bin/vncserverui virtual 15
root       755   732  0 21:00 ?        00:00:00 /usr/bin/vncserverui -statusicon 5
root      1260  1188  0 21:20 pts/0    00:00:00 grep vnc

Also ‘ss -alnp | grep Xvnc-core’ looks better

ss -alnp | grep Xvnc-core
u_str  LISTEN  0        0                                     /tmp/.X11-unix/X1 15363                                                   * 0                      users:(("Xvnc-core",pid=684,fd=3))
u_str  LISTEN  0        0                        /tmp/.vnc-0/Xvnc.CtrlComms.1.0 15389                                                   * 0                      users:(("Xvnc-core",pid=684,fd=9))
tcp    LISTEN  0        5                                                                         *                      users:(("Xvnc-core",pid=684,fd=7))
tcp    LISTEN  0        128                                                                       *                      users:(("Xvnc-core",pid=684,fd=1))
tcp    LISTEN  0        5                                                  [::]:5901                                                 [::]:*                      users:(("Xvnc-core",pid=684,fd=6))
tcp    LISTEN  0        128                                                [::]:6001                                                 [::]:*                      users:(("Xvnc-core",pid=684,fd=0))

Still can’t connect tho. Same error of ‘Cannot currently show the desktop’

Ok that looks good now. You should be able to connect using IP:1 or IP:5901. Thats the port the vnc is running on as you can see on your output above.