RealVNC service fails to start

trying to use realvnc in a headless setup. It was working at one point, but now the vncserver service is failed. tried reinstalling, rebooting, etc but no luck. any ideas?

pls share following

systemctl status vncserver
journalctl -u vncserver
ss -tulpn | grep LISTEN

I was able to get the service to start by setting a password for VNC, but now when I attempt to connect from VNC viewer, I get an immediate “connection was refused by the computer”

dietpi@DietPi:~$ dietpi@DietPi:~$ systemctl status vncserver
● vncserver.service - VNC Server (DietPi)
     Loaded: loaded (/etc/systemd/system/vncserver.service; enabled; vendor preset: enabled)
     Active: active (exited) since Thu 2021-11-04 18:20:36 GMT; 7h ago
    Process: 429 ExecStart=/usr/local/bin/vncserver start (code=exited, status=0/SUCCESS)
   Main PID: 429 (code=exited, status=0/SUCCESS)
        CPU: 23ms



root@DietPi:~# journalctl -u vncserver
-- Journal begins at Thu 2021-11-04 18:20:35 GMT, ends at Fri 2021-11-05 01:51:54 GMT. --
Nov 04 18:20:36 DietPi systemd[1]: Started VNC Server (DietPi).
Nov 04 18:20:36 DietPi systemd[429]: pam_unix(login:session): session opened for user root(uid=0) by (uid=0)
Nov 04 18:20:37 DietPi vncserver[429]: [  OK  ] RealVNC detected
Nov 04 18:20:37 DietPi vncserver[429]: [ INFO ] Starting virtual desktop at display :1 in 1280x720x16



root@DietPi:~# journalctl -u vncserver
-- Journal begins at Thu 2021-11-04 18:20:35 GMT, ends at Fri 2021-11-05 01:51:54 GMT. --
Nov 04 18:20:36 DietPi systemd[1]: Started VNC Server (DietPi).
Nov 04 18:20:36 DietPi systemd[429]: pam_unix(login:session): session opened for user root(uid=0) by (uid=0)
Nov 04 18:20:37 DietPi vncserver[429]: [  OK  ] RealVNC detected
Nov 04 18:20:37 DietPi vncserver[429]: [ INFO ] Starting virtual desktop at display :1 in 1280x720x16



root@DietPi:~# ss -tulpn | grep LISTEN
tcp   LISTEN 0      5          127.0.0.1:4711       0.0.0.0:*    users:(("pihole-FTL",pid=516,fd=10))                    
tcp   LISTEN 0      5            0.0.0.0:5901       0.0.0.0:*    users:(("Xvnc-core",pid=547,fd=7))                      
tcp   LISTEN 0      4096         0.0.0.0:111        0.0.0.0:*    users:(("rpcbind",pid=293,fd=4),("systemd",pid=1,fd=33))
tcp   LISTEN 0      1024         0.0.0.0:80         0.0.0.0:*    users:(("lighttpd",pid=765,fd=4))                       
tcp   LISTEN 0      64           0.0.0.0:43057      0.0.0.0:*                                                            
tcp   LISTEN 0      128          0.0.0.0:6001       0.0.0.0:*    users:(("Xvnc-core",pid=547,fd=1))                      
tcp   LISTEN 0      32           0.0.0.0:53         0.0.0.0:*    users:(("pihole-FTL",pid=516,fd=5))                     
tcp   LISTEN 0      1000         0.0.0.0:22         0.0.0.0:*    users:(("dropbear",pid=328,fd=4))                       
tcp   LISTEN 0      256        127.0.0.1:5335       0.0.0.0:*    users:(("unbound",pid=457,fd=4))                        
tcp   LISTEN 0      256        127.0.0.1:8953       0.0.0.0:*    users:(("unbound",pid=457,fd=6))                        
tcp   LISTEN 0      64              [::]:45981         [::]:*                                                            
tcp   LISTEN 0      512                *:7878             *:*    users:(("Radarr",pid=770,fd=146))                       
tcp   LISTEN 0      5              [::1]:4711          [::]:*    users:(("pihole-FTL",pid=516,fd=15))                    
tcp   LISTEN 0      5               [::]:5901          [::]:*    users:(("Xvnc-core",pid=547,fd=6))                      
tcp   LISTEN 0      4096            [::]:111           [::]:*    users:(("rpcbind",pid=293,fd=6),("systemd",pid=1,fd=35))
tcp   LISTEN 0      1024            [::]:80            [::]:*    users:(("lighttpd",pid=765,fd=5))                       
tcp   LISTEN 0      128             [::]:6001          [::]:*    users:(("Xvnc-core",pid=547,fd=0))                      
tcp   LISTEN 0      128                *:21               *:*    users:(("proftpd",pid=735,fd=0))                        
tcp   LISTEN 0      32              [::]:53            [::]:*    users:(("pihole-FTL",pid=516,fd=7))                     
tcp   LISTEN 0      1000            [::]:22            [::]:*    users:(("dropbear",pid=328,fd=5))                       
tcp   LISTEN 0      256            [::1]:8953          [::]:*    users:(("unbound",pid=457,fd=5))

looks all fine and VNC seems to be running using desktop ID 1

Yup that was the problem, wasn’t putting the :1 at the end of the IP address. Thanks!

Try the following workaround:

cd /usr/lib/arm-linux-gnueabihf
dpkg -L libraspberrypi0 | grep '/usr/lib/arm-linux-gnueabihf/.*\.so.0' | while read -r line
do
line=${line#/usr/lib/arm-linux-gnueabihf/}
ln -s "$line" "${line%.0}"
done
systemctl restart vncserver

It’s already fixed MichaIng

Ah right, probably not an RPi or ARMv8 image.