Don't judge me for using TeamViewer, we have commercial license and I am stuck with it for most deployments. It is a very poorly supported product designed by some marketing team.
I had the strangest problem with this Raspberry Pi installed on top of a hill far from anywhere, running some network monitoring tools. It is running Debian 10 with XFCE DE. Upon set up everything was fine but the next day I was unable to connect, getting the above error message. This did not make any sense.
Went back few days later and after some frustration I've connected monitor to the RPi and everything suddenly worked fine. There seem to be an issue with how the TeamViewer on RPi (and other linux boxes) handle having no display connected.
The solution:
On the RPi I've modified
/boot/config.txt
Code:
# 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=1
hdmi_mode=31
More information on this config file at
https://elinux.org/RPi_Configuration
https://elinux.org/R-Pi_configuration_file
Searching for solutions to (many) TeamViewer issues will bring up years old threads mostly without any positive outcomes.