Rancher web interface complains "waiting for cluster agent to connect" when installing first node

I am provisioning an rke2 cluster and rancher complains when installing the first node about:

waiting for cluster agent to connect
rke version is v1.24.13+rke2r1

Which agent is failing and how can I troubleshoot this?

Have you solved this problem

At this point the cluster might be ready as standalone but not active on Rancher Manager. If you have SSH access to the nodes, export the KUBECONFIG=/etc/rancher/rke2/rke2.yaml and get the cattle-cluster-agent pods in the cattle-system namespace. Describe the pod or check the pod logs to troubleshoot why the pod is not able to connect to Rancher.

I faced this issue once, in my case the cattle-cluster-agent pod was not able to resolve my Rancher FQDN. After restarting my coredns deployment the issue got resolved.