Hi!
Cardano-cli connects to cardano-node via socket. The socket “exists” when cardano-node has finished starting up - all databases opened.