Issue report #24810 reminds me that I've been seeing a similar issue since several months on master built with --enable-debug in my development environment, where the CLI becomes unresponsive and eventually returns:
error: timeout on transient error: Could not connect to the server 127.0.0.1:8332 (error code 0 - "timeout reached")
Make sure the bitcoind server is running and that you are connecting to the correct RPC port.
Once the CLI becomes unresponsive, it seems to happen with any CLI command. This didn't occur for me with v21 and I'm not sure about v22, as IIRC it began sometime last Fall (2021) for me. Until now I've been discounting it as something related to my local environment and working around it by restarting, since I restart very often for review and testing.
Debian testing, currently Debian 5.16.18-1 (2022-03-29) x86_64 GNU/Linux.
I'm going to try to narrow down the issue more.
Is anyone else running into this?