Time needed: 3 minutes.
If you installed a remote connection to your Raspberry Pi using VNC, it can happen you get a black screen with an error message ‘Cannot currently show the desktop’ on your next connection attempt. In this short tutorial we’ll see how you can fix this issue easily.
For this tutorial, our Pi is running on Raspberry Pi OS. And we assume you already established a remote connection using the RealVNC software. Have a look at our tutorial ‘Access your Raspberry Pi remotely from another computer‘ if this isn’t the case or if you need additional information.
- Reconnect temporarily a monitor to your Raspberry Pi
The black screen comes when you boot your remote Pi while it isn’t connected to a monitor and you left the default screen resolution. To solve this issue and be able to boot without a monitor connected to your remote Pi, we have to change the Pi’s screen resolution. So, to be able to change the configurations, you temporarly need to have a monitor connected to your Pi and forget the remote connect for a short while.
- Boot your Raspberry Pi and open a terminal window
Once you have back your screen on your Pi, click on the terminal icon on the taskbar (left upper corner of your screen), a terminal window will appear.
- Switch to root user
First, enter :
- Change the display setting
Then, enter or copy and paste :
echo 'hdmi_group=2'>> /boot/config.txt
echo 'hdmi_mode=51'>> /boot/config.txt
There are different ways how to change your display settings. In any case, these settings are kept in your config.txt file.
It’s optional, but if you want to visualise the changes you just made in your config.txt file, enter :
Have a look at the bottom of the file.
Now you can remove the HDMI-cable from your Pi if you want. A monitor directly connected to your Pi isn’t necessary anymore to have your screen back on the VNC viewer.
Finally, enter :
- Reconnect remotely with your VNC viewer.
That’s it ! Now you can establish a remote connection to your Raspberry Pi again. And if you executed previous steps carefully, the black screen with ‘Cannot currently show the desktop’ won’t appear any more.
In most cases, the best screen resoltion for the VNC viewer is ‘DMT Mode 51’. But if you want to change the display settings to a lower resolution for example, you still can do it with the Raspberry Pi Software Configuration Tool (raspi-config). You’ll find more information how to use this tool in the Raspberry Pi documentation : https://www.raspberrypi.org/documentation/computers/configuration.html