Setting up a "headless" VNC server on Raspberry Pi

October 13, 2022
This is our procedure for setting up a VNC server on a Raspberry Pi running Raspbian 11 that has no monitor, keyboard, or mouse. Before the exit line in /etc/rc.local, add this:
su pi -c 'vncserver -randr=1870x980'
You can adjust the resolution to your specifications. Note that with this technique, you will connect to Display 1. If your Pi's IP address is, connect to We used RealVNC's VNC Viewer for this purpose. trlaing on the Raspberry Pi Forums gave us a tip about correcting window display:
sudo nano /etc/xdg/lxsession/LXDE-pi/desktop.conf
Change window_manager to the following:
Our friends at Griffon's IT Library know how to fix the "Authentication required to refresh system repositories" popup.
sudo echo -e ""\
"[Allow Package Management all Users]\n"\
> 46-allow-update-repo.pkla
sudo mkdir -p /etc/polkit-1/localauthority/50-local.d/
sudo mv 46-allow-update-repo.pkla /etc/polkit-1/localauthority/50-local.d/