Running without a head does not start properly unless a screen is connected

I want to use Ubuntu 18 without a head and connect to AnyDesk. Everything works fine as long as a screen is connected even when it is not turned on. If no display is connected, AnyDesk connects but with a black screen at startup. When I next attach a monitor to watch it, it starts, but it seems like it is on the screen of activity.

Even by unplugging it after startup and being connected to AnyDesk, things get complicated. But if I reconnect the screen, everything works again.

I tried to change the resolution, but that did not seem to help.

I am a novice in Linux, so I do not know where to look for log files or anything that would tell me what's going on.

Any help would be appreciated.