VNC connection refused on Raspberry Pi 4

I have a Raspberry Pi 4 running the default OS and VNC has been turned on and working for many weeks now. Suddenly today I tried to connect to the RPi using the VNC client on my iPhone and an error occurred. The error message shown is An authentication error occurred. See the VNC Server error log for details. I ran the following commands and got these results:

cat /var/log/syslog | grep vnc | tail

[...]
Apr 28 22:06:37 raspberrypi vncserver-x11[623,root]: Connections: connected: 192.168.0.204::60769 (TCP)
Apr 28 22:06:46 raspberrypi vncserver-x11[623,root]: SAuthUserPasswd: Auth error: /: permissions are not restrictive enough
Apr 28 22:06:46 raspberrypi vncserver-x11[623,root]: Connections: disconnected: 192.168.0.204::60769 (TCP) ([AuthError] An authentication error occurred.  See the VNC Server error log for details.)

sudo cat /var/log/vncserver-x11.log

[...]
<13> 2022-04-30T18:50:18.417Z raspberrypi vncserver-x11[613]: Connections: connected: 192.168.0.204::61654 (TCP)
<14> 2022-04-30T18:50:18.421Z raspberrypi vncserver-x11[613]: SConnection: Client needs protocol version 5.0
<14> 2022-04-30T18:50:18.421Z raspberrypi vncserver-x11[613]: SProtoV5Up: Choosing cipher suite RA4_128 [0x0202] (algorithms: RSA-OAEP, ECDHE-Curve25519, SHA-256, AES-GCM-128)
<14> 2022-04-30T18:50:18.507Z raspberrypi vncserver-x11[613]: SAuthProtoImpl: Offering auth method UserPasswd(1) [required=1]
<14> 2022-04-30T18:50:18.512Z raspberrypi vncserver-x11[613]: SAuthProtoImpl: Client chose auth method UserPasswd(1)
<11> 2022-04-30T18:50:27.658Z raspberrypi vncserver-x11[613]: SAuthUserPasswd: Auth error: /: permissions are not restrictive enough
<13> 2022-04-30T18:50:27.658Z raspberrypi vncserver-x11[613]: Connections: disconnected: 192.168.0.204::61654 (TCP) ([AuthError] An authentication error occurred.  See the VNC Server error log for details.)
<14> 2022-04-30T18:50:27.659Z raspberrypi vncserver-x11[613]: SMsgWriter: framebuffer updates 0
<14> 2022-04-30T18:50:27.659Z raspberrypi vncserver-x11[613]: SMsgWriter:   CopyRect rects 0, bytes 0, pixels 0
<14> 2022-04-30T18:50:27.659Z raspberrypi vncserver-x11[613]: SMsgWriter:   raw bytes equivalent 0, compression ratio nan

(these lines appear every time I try to connect)

I really don't understand why this stopped working all of a sudden. Although I have services like docker and home assistant running continuously, I did not install or change anything myself in between VNC working and not working.

I have searched for this error to understand what it means and how to solve this but have really found nothing related to VNC or even just this error message in general.

1

Comments

17 comments
  • I have the same issue on my raspberry pi 4 (debian bullseye 64-bit) with realvnc-vnc-server v6.9.1.46706

    <11> 2022-05-01T16:30:57.314Z voiphome vncserver-x11[4082]: SAuthUserPasswd: Auth error: /: permissions are not restrictive enough

     

     

    1
    Comment actions Permalink
  • Yes, 6.9.1.46706 is exactly my version too.

    0
    Comment actions Permalink
  • Hi there,

    We're sorry to hear about this issue. The error message indicates that the permissions on the root directory (/) aren't secure enough. Have you changed any permissions on this directory?

    0
    Comment actions Permalink
  • No, I haven't. Like I said above, as far as I know, nothing changed before this stopped working.

    0
    Comment actions Permalink
  • Hi Alex,

    Please can you share the output of this command?

    ls -la /

    0
    Comment actions Permalink
  • pi@raspberrypi:~ $ ls -la /
    total 88
    drwxr-xr-x  18 pi   root  4096 May  1 16:02 .
    drwxr-xr-x  18 pi   root  4096 May  1 16:02 ..
    lrwxrwxrwx   1 root root     7 Jan 28 03:58 bin -> usr/bin
    drwxr-xr-x   5 root root  3584 Jan  1  1970 boot
    drwxr-xr-x  17 root root  4040 Apr 29 00:56 dev
    -rw-rw-r--   1 pi   pi    4096 Apr  2 03:15 ._.DS_Store
    -rw-rw-r--   1 pi   pi    6148 Apr 28 23:53 .DS_Store
    drwxr-xr-x 125 root root 12288 Apr 28 21:36 etc
    drwxr-xr-x   3 root root  4096 Jan 28 04:00 home
    lrwxrwxrwx   1 root root     7 Jan 28 03:58 lib -> usr/lib
    drwx------   2 root root 16384 Jan 28 04:20 lost+found
    drwxr-xr-x   3 root root  4096 Apr  2 01:17 media
    drwxr-xr-x   2 root root  4096 Jan 28 03:58 mnt
    drwxr-xr-x   4 root root  4096 Apr  5 00:50 opt
    dr-xr-xr-x 321 root root     0 Jan  1  1970 proc
    drwx------   5 root root  4096 Apr  6 14:20 root
    drwxr-xr-x  29 root root   940 May  4 15:43 run
    lrwxrwxrwx   1 root root     8 Jan 28 03:58 sbin -> usr/sbin
    drwxr-xr-x   2 root root  4096 Jan 28 03:58 srv
    dr-xr-xr-x  12 root root     0 Jan  1  1970 sys
    drwxrwxrwt  10 root root  4096 May  4 15:43 tmp
    drwxr-xr-x  11 root root  4096 Jan 28 03:58 usr
    drwxr-xr-x  11 root root  4096 Jan 28 04:22 var
    0
    Comment actions Permalink
  • Hi Alex,

    Many thanks. I believe the issue is that the directory itself is owned by pi , instead of root, which is what I see on a working system. I will speak to our engineers to see if this is the case, and why it might have changed on your system.

    0
    Comment actions Permalink
  • Thank you. I will then wait for your answer.

    So normally, is the root directory owned by pi or root?

    0
    Comment actions Permalink
  • Hi Alex,

    On a Pi Bullseye image I set up earlier today, it is owned by root.

    0
    Comment actions Permalink
  • I checked the permission of this folder on some other raspberry pi that I had, and found that the / folder should be owned by root and should have a permission mode of 755. Not sure why the permission mode fo this folder was changed to 775 and was also owned by pi user rather than root user on this raspberry pi that I had.

    I reset the permission mode to 755 and the owner to root for both / and /usr folders and it started to work.

     

    0
    Comment actions Permalink
  • I can also confirm this works. Just ran this command

    sudo chown root /

    and VNC now works again. Thank you for all the help!

    0
    Comment actions Permalink
  • Hi both,

    I'm pleased to hear that VNC Server is authenticating correctly with the ownership corrected to root. We're not sure why it was changed to your pi on your devices, we think it must have been triggered by another application or service on the device.

    Mostafa, are you also running either of Home Assistant or Docker?

    0
    Comment actions Permalink
  • No, however I am running samba, asterisk and a buch of other services. Here is a list of all packages installed on the rpi

    https://pastebin.com/ZgLSYA17

    and the list of all services on the rpi:

    https://pastebin.com/rQTMJ2Cp

    0
    Comment actions Permalink
  • I am also running samba! If you let me know the commands you ran to generate those lists, I can also upload mine.

    0
    Comment actions Permalink
  • I used these commands:

    dpkg-query -f '${Package}###${Version}\n' -W

    systemctl list-units --type=service

     

    0
    Comment actions Permalink
  • Jack N RealVNC

    I am facing access denied issue for non root user when trying to access vnc server via vnc client viewer,i tried to search alot but did not find any fix.Can you guide me?

    I am using rasberrypi ,working ok with root/sudo user bot not with non-sudo user

    0
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post