How I fixed Ubuntu BOINC Invalid client RPC password. Try reinstalling BOINC

Whenever I started boinc-manager after upgrading to Ubuntu 21.10, it couldn’t connect to the BOINC client, stating that:

Invalid client RPC password. Try reinstalling BOINC

This is how I solved it.

First, generate a new RPC password using:

# Generate new RPC password
sudo apt -y install pwgen
pwgen 30 1 | sudo tee /etc/boinc-client/gui_rpc_auth.cfg
# Fix some permissions
sudo chown root:boinc /etc/boinc-client/gui_rpc_auth.cfg
sudo chown root:boinc /var/lib/boinc/gui_rpc_auth.cfg
# Add current user to BOINC group
sudo usermod -a -G boinc $USER
# Restart BOINC client
sudo systemctl restart boinc-client

After that, retry restarting boincmgrIf the error still persists, reboot and retry!