VNC on Raspberry Pi shows Cannot Currently Show the Desktop
Asked Answered
J

6

9

I am trying to use VNC in a headless install on my Raspberry Pi 4, running Raspberry Pi OS, installed via Raspberry Imager. The install is more or less vanilla, as the only changes I have made are for connecting (seting up SSH, wireless and VNC as noted in this guide: https://www.tomshardware.com/reviews/raspberry-pi-headless-setup-how-to,6028.html).

When I log in via VNC I get the "Cannot Currently Show the Desktop"-error. It should be possible to fix by changing the screen resolution via raspi-config, but that makes the pi unresponsive. Setting the pi to use "G3 legacy" should fix that issue either after a reboot or without (answers vary on that), but it doesn't seem to make a difference in either case.

Does anyone know how I can get to connect via VNC to my pi?

Thanks :)

Jacinthe answered 30/3, 2021 at 17:9 Comment(0)
E
9

According to the documentation:

If your Raspberry Pi is headless (i.e. not plugged into a monitor) or controlling a robot, it is unlikely to be running a graphical desktop.

So the idea is to create a new virtual desktop via vncserver-virtual command and use the display number in VNC.

Additional info here.

Eloquent answered 19/4, 2021 at 21:2 Comment(3)
I owe you a beverage of your choice. Took me 2 days of reading guides and this is what was missing in all of them.Apiculate
Happy to help @CanonicalBear!Eloquent
I was stuck in the same loop of reading tutorials and not having any success with the steps they provided. Running vncserver was all I needed to do. Thanks for this @ApiculateDacey
P
4

Raspbian Buster:

  1. Launch command line and run:

    sudo raspi-config

  2. Display options -> Resolution. Then select a resolution mode, I recommend select 1280x720 but you can also choose the higher resolution (1920x1080). Save and finish.

  3. Reboot and connect to raspberry again through VNC client.

Raspbian Bullseye:

  1. Launch command line and run:

    sudo raspi-config

  2. Display options -> VNC Resolution. Then select a resolution mode, I recommend select 1280x720 but you can also choose the higher resolution (1920x1080). Save and finish.

  3. Reboot and connect to raspberry again through VNC client.

Perugia answered 15/9, 2021 at 18:3 Comment(2)
This used to work, but now appears broken with the latest Raspbian.Logsdon
Same for me it doesn't work for Raspbery Pi 4 B (the latest OS update).Mythical
C
3

Basically should be sufficient to specify a HDMI mode. I have a Raspberry Pi4 headless, this is my configuration in /boot/config.txt

# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
hdmi_group=2
hdmi_mode=82

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d
gpu_mem=128
start_x=1
enable_uart=1
#hdmi_enable_4kp60=1

Then I disabled encryption and set a VNC password. In addition, if you to see the raspistill/raspivid preview through VNC you have to enable this: RealVNC Viewer > Menu > Options > Troubleshooting > Optimize screen capture - select 'Enable direct capture mode'

Contrastive answered 31/3, 2021 at 14:1 Comment(2)
Hi rok. Thank you for answering. i have copy pasted your config file onto my pi, but it makes no differnce. My pi still hangs whenever I try to access screen resolution, and I can't get a desktop via VNC :(Jacinthe
I don't understand what you mean by " I try to access screen resolution".. just copy settings from my config file to your.. it already contains the screen resolution settings. I suggest you to try with a fresh install of raspbian.Contrastive
E
3

My Rpi4 Bullseye machine had set itself into safe mode … in /boot/config.txt the line

hdmi_safe=1

Was uncommented.

Commenting it out fixed my lo-resolution VNC display problem

Then had to reboot, then logout, and login for everything to be set ok

Earhart answered 17/1, 2023 at 18:57 Comment(0)
W
2

This solved the problem for me: https://www.shellhacks.com/raspberry-pi-force-hdmi-hotplug/.

Woolcott answered 7/1, 2022 at 13:28 Comment(1)
Uncommenting hdmi_force_hotplug=1 fixed the issue for me as wellSiloum
S
0

TL;DR

Setting the resolution of VNC in Raspberry Pi (RPi):

/usr/bin/xrandr --fb 1920x1080

Long answer

One can examine the code of raspi-config bash script, here

Look for the do_vnc_resolution function.

Sangria answered 19/10, 2022 at 19:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.