Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

RPi4B with Buster - VNC not working....

Tue Jul 09, 2019 11:14 am

I have installed and upgraded the Raspbian Buster on my new RPi4B 4GB box. It is all up to date.
The installation was done headless because I have no monitor for the RPi4, so I have access only vua PuTTY and want to use the desktop via VNC.

So in raspi-config I have enabled VNC too.

But when I try to connect using Real-VNC I get to a login screen where I enter my login credentials (pi and the changed pi password).
Then after a while there is a screen saying "Cannot currently show the desktop"..

What is the cause for this and what can I do to fix it?
Bo Berglund
Sweden

Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

Re: RPi4B with Buster - VNC not working....

Tue Jul 09, 2019 12:04 pm

I have currently set my RPi4 to boot to the CLI rather than the GUI in raspi-config (B1).
Is this what is preventing the VNC connection showing the desktop?

I would have believed that the VNC desktop should be created when the user connects via VNC and not sitting there all the time with no user...
Bo Berglund
Sweden

pcmanbob
Posts: 7306
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: RPi4B with Buster - VNC not working....

Tue Jul 09, 2019 12:25 pm

If the GUI is not running then there is nothing for VNC to show that's why you are getting the "Cannot currently show the desktop" message ,

I believe you can set VNC to show a virtual desktop if the GUI is not running, but as I have never tried it I can't offer any set-up advice.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

klricks
Posts: 6627
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: RPi4B with Buster - VNC not working....

Tue Jul 09, 2019 12:29 pm

Bosse_B wrote:
Tue Jul 09, 2019 12:04 pm
I have currently set my RPi4 to boot to the CLI rather than the GUI in raspi-config (B1).
Is this what is preventing the VNC connection showing the desktop?

I would have believed that the VNC desktop should be created when the user connects via VNC and not sitting there all the time with no user...
1 - With Buster you must set a specific screen resolution in sudo raspi-config (Not default monitor).
2 - If booting to the CLI then you can't use RealVNC in service mode. Use virtual mode instead.

Code: Select all

vncserver
Then connect with IP_address:1 as shown in the startup message.
(It is not necessary to enable VNC in raspi-config when using virtual mode).
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

Re: RPi4B with Buster - VNC not working....

Tue Jul 09, 2019 1:07 pm

I changed the raspi-config boot option to boot into the GUI but require login.
I also modified the /etc/rc.local file by adding this at the end before exit:

#Start RealVNC in virtual mode with resolution 1400x900 px
vncserver -randr=1400x900

(I noted that this was present in my RPi3B unit where VNC works already.)

After a reboot I am now able to connect VNC!
Problem solved!

Notice that I am not able to run the RPi4 with a monitor since:
a) The PC monitor where I am now does not have HDMI
b) And I don't own a micro-HDMI cable anyway.
Bo Berglund
Sweden

Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

Re: RPi4B with Buster - VNC not working....

Wed Jul 10, 2019 10:08 pm

Bosse_B wrote:
Tue Jul 09, 2019 1:07 pm
I also modified the /etc/rc.local file by adding this at the end before exit:

#Start RealVNC in virtual mode with resolution 1400x900 px
vncserver -randr=1400x900
Unfortunately this was only half a solution....
The screen created by the rc.local command is inaccessible because it is owned by root and the pi login is not accepted.
So no vncserver command inside /etc/rc.local!!!

Instead I use cron to handle this, see below.
I need to adapt the VNC window to my actual PC desktop (1920x1080) such that the VNC window uses about 1400x900 pixels.
This way I can work decently inside the Pi for development and still have access easily to my Windows desktop.
For some reason this discussion wandered into my other RPi4 thread...
But I will recap the solution here:

1) Do not enable VNC in raspi-config! If already done then go back and change to NOT enabled.

2) From the PuTTY CLI logged in as pi edit the cron table:

Code: Select all

$ crontab -e
Put the following into it (set the screen geometry as you want):

Code: Select all

@reboot sleep 60 && /usr/bin/vncserver -randr=1400x900
This will start vncserver 60 seconds after reboot with the size of the virtual desktop set.
Reboot the RPi to check

3) In RealVNC you create a connection where the address is <hostname or IP address>:1
Like myrpi4machine:1

You should now be able to log in via VNC and see a desktop sized as per your wish in the crontab command.
Bo Berglund
Sweden

klricks
Posts: 6627
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: RPi4B with Buster - VNC not working....

Wed Jul 10, 2019 11:32 pm

Bosse_B wrote:
Wed Jul 10, 2019 10:08 pm
Bosse_B wrote:
Tue Jul 09, 2019 1:07 pm
I also modified the /etc/rc.local file by adding this at the end before exit:

#Start RealVNC in virtual mode with resolution 1400x900 px
vncserver -randr=1400x900
Unfortunately this was only half a solution....
The screen created by the rc.local command is inaccessible because it is owned by root and the pi login is not accepted.
So no vncserver command inside /etc/rc.local!!!
....
..
You can start vncserver as user pi from /etc/rc.local like this:

Code: Select all

sudo -u pi vncserver -randr=1400x900
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

Re: RPi4B with Buster - VNC not working....

Thu Jul 11, 2019 8:41 am

klricks wrote:
Wed Jul 10, 2019 11:32 pm
You can start vncserver as user pi from /etc/rc.local like this:

Code: Select all

sudo -u pi vncserver -randr=1400x900
Thanks,
I did not know that you could set the user when starting something from rc.local.
Now back to using this rather than cron and it works just fine!
Bo Berglund
Sweden

Return to “Raspbian”