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.
Comments
I have the same issue on my raspberry pi 4 (debian bullseye 64-bit) with realvnc-vnc-server v6.9.1.46706
Yes, 6.9.1.46706 is exactly my version too.
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?
No, I haven't. Like I said above, as far as I know, nothing changed before this stopped working.
Hi Alex,
Please can you share the output of this command?
ls -la /
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.
Thank you. I will then wait for your answer.
So normally, is the root directory owned by pi or root?
Hi Alex,
On a Pi Bullseye image I set up earlier today, it is owned by root.
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.
I can also confirm this works. Just ran this command
and VNC now works again. Thank you for all the help!
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?
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
I am also running samba! If you let me know the commands you ran to generate those lists, I can also upload mine.
I used these commands:
https://pastebin.com/9VyJwi6x
https://pastebin.com/WDUScqbv
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
I had exactly the same issue like the one describied above
plus I was not able to access my freshly installed raspbian ssh as well
(I already enabled ssh and vnc from raspi-config before this step)
it seems like this is not realvnc issue but OS itself.
I tried chown method suggested above, but it did not work on my case.
I just find out the solution for my case
1. go to raspberry pi application menu(rasberry pi icon on top left corner)
>> preferences >> raspberry pi cofiguration
2. in system tab, click change passwrod
3. change your password of your own and reboot
then ssh and vnc will work as normal
I wish it helps someone in needs
Please sign in to leave a comment.