Without X, if the console driver detects no connected displays at boot time, it will switch to a "dummy console" mode and won't automatically switch back out of it once a display is plugged in, which will result in the problem you've experienced.
See Documentation/fb/modedb.rst in Linux kernel documentation.
You will need to specify a kernel boot option that forces the HDMI output to be active, even if it isn't plugged in at boot time.
For example, on my previous home server system I used the boot option:
video=HDMI-A:1920x1080-32D
to force the HDMI-A output to be always enabled (the D letter at the end does that), and to always use a particular resolution that was suited to my display; otherwise, when started with the display unplugged, it would have defaulted to some standard VGA/SVGA resolution like 1024x768 which was just tiny on my display.
sudo journalctl -b 0 -x, and when you plug in the HDMI (failure):sudo journalctl --since="-5 minutes" -x.