I have a Raspberry pi 4 8GB ram version, where I installed Ubuntu 21.10 64bit version.
In order to avoid having to carry a screen while traveling, I started using VNC Viewer on my personal computer. So in "settings"->"Sharing"->"Screen Sharing" I put the following settings:
I noticed that every time I rebooted the raspberry pi, the "Screen Sharing" password was "forgotten". After some research https://askubuntu.com/questions/1296932/screen-sharing-in-unusable-state-after-rebooting, I found out that there is a bug in Ubuntu that for each reboot the password for "Screen Sharing" was cleared. The alternative to solve this situation would be to go to the "Passwords and Keys" application in login, change the password to a blank password (of course it's not secure at all, but at least it solved it):
In summary now every time I reboot these "Screen sharing" settings are saved.However, I am now being faced with another problem:
If I reboot the Raspberry pi but with the hdmi cable connected directly to an external monitor, I can from my personal computer connect to the raspberry pi via VNC Viewer.
On the other hand, if the Raspberry pi is not connected to an external monitor by the hdmi cable, at the end of a reboot, when I try to connect to the raspberry pi via VNC Viewer, I am confronted with the following message:
"Connection refused by the computer"
What I am finding strange is that if I next reboot with an external screen, I find that the "Screen Sharing" settings, remain intact.
Given this situation, I would like to know if anyone else has been confronted with this situation and if there is a solution.
Thank you very much for your attention.